Backup and restore fin files if they exist

This commit is contained in:
Bob Mottram 2016-03-07 17:26:46 +00:00
parent 05d7d8dcd2
commit 0e247a521c
4 changed files with 111 additions and 44 deletions

View File

@ -289,6 +289,12 @@ function backup_users {
backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME
fi
# Backup fin database if it exists
if [ -d /home/$USERNAME/.fin ]; then
echo $"Backing up fin files for $USERNAME"
backup_directory_to_usb /home/$USERNAME/.fin fin/$USERNAME
fi
# Backup user configs
if [ -d /home/$USERNAME/.config ]; then
echo $"Backing up config files for $USERNAME"

View File

@ -208,6 +208,12 @@ function backup_users {
backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME
fi
# fin files
if [ -d /home/$USERNAME/.fin ]; then
echo $"Backing up fin files for $USERNAME"
backup_directory_to_friend /home/$USERNAME/.fin fin/$USERNAME
fi
# local files
if [ -d /home/$USERNAME/.local ]; then
echo $"Backing up local files for $USERNAME"

View File

@ -601,6 +601,33 @@ function restore_user_config {
fi
}
function restore_user_fin {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'userfin' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/fin ]; then
for d in $USB_MOUNT/backup/fin/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
fi
echo $"Restoring fin files for $USERNAME"
restore_directory_from_usb /root/tempfin fin/$USERNAME
cp -r /root/tempfin/home/$USERNAME/.fin /home/$USERNAME/
if [ ! "$?" = "0" ]; then
rm -rf /root/tempfin
unmount_drive
exit 664
fi
rm -rf /root/tempfin
fi
done
fi
}
function restore_user_local {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'userlocal' ]]; then
@ -1097,6 +1124,7 @@ restore_admin_readme
restore_ipfs
restore_user_ssh_keys
restore_user_config
restore_user_fin
restore_user_local
restore_certs
restore_personal_settings

View File

@ -481,6 +481,32 @@ function restore_user_config {
done
}
function restore_user_fin {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'userfin' ]]; then
return
fi
fi
for d in $SERVER_DIRECTORY/backup/fin/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/fin/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
fi
echo $"Restoring fin files for $USERNAME"
restore_directory_from_friend /root/tempfin fin/$USERNAME
cp -r /root/tempfin/home/$USERNAME/.fin /home/$USERNAME/
if [ ! "$?" = "0" ]; then
rm -rf /root/tempfin
exit 664
fi
rm -rf /root/tempfin
fi
fi
done
}
function restore_user_local {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'userlocal' ]]; then
@ -950,6 +976,7 @@ restore_admin_readme
restore_ipfs
restore_ssh_keys
restore_user_config
restore_user_fin
restore_user_local
restore_certs
restore_personal_settings