Backup user files in .local

Which includes profanity settings
This commit is contained in:
Bob Mottram 2016-03-03 09:09:29 +00:00
parent 1f021fb5a2
commit 07427dcbda
4 changed files with 67 additions and 0 deletions

View File

@ -295,6 +295,12 @@ function backup_users {
backup_directory_to_usb /home/$USERNAME/.config config/$USERNAME
fi
# Backup user local
if [ -d /home/$USERNAME/.local ]; then
echo $"Backing up local files for $USERNAME"
backup_directory_to_usb /home/$USERNAME/.local local/$USERNAME
fi
# Backup mutt
if [ -f /home/$USERNAME/.muttrc ]; then
echo $"Backing up Mutt settings for $USERNAME"

View File

@ -204,6 +204,12 @@ function backup_users {
backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME
fi
# local files
if [ -d /home/$USERNAME/.local ]; then
echo $"Backing up local files for $USERNAME"
backup_directory_to_friend /home/$USERNAME/.local local/$USERNAME
fi
# mutt settings
if [ -f /home/$USERNAME/.muttrc ]; then
echo $"Backing up Mutt settings for $USERNAME"

View File

@ -596,6 +596,33 @@ function restore_user_config {
fi
}
function restore_user_local {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'userlocal' ]]; then
return
fi
fi
if [ -d $USB_MOUNT/backup/local ]; then
for d in $USB_MOUNT/backup/local/*/ ; 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 local files for $USERNAME"
restore_directory_from_usb /root/templocal local/$USERNAME
cp -r /root/templocal/home/$USERNAME/.local /home/$USERNAME/
if [ ! "$?" = "0" ]; then
rm -rf /root/templocal
unmount_drive
exit 664
fi
rm -rf /root/templocal
fi
done
fi
}
function restore_certs {
if [[ $RESTORE_APP != 'all' ]]; then
if [[ $RESTORE_APP != 'certs' ]]; then
@ -1065,6 +1092,7 @@ restore_admin_readme
restore_ipfs
restore_user_ssh_keys
restore_user_config
restore_user_local
restore_certs
restore_personal_settings
restore_mailing_list

View File

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