Backup and restore any user config files
This commit is contained in:
parent
bda3303a4d
commit
3421108c6c
|
@ -2823,6 +2823,21 @@ function create_backup_script {
|
|||
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
|
||||
echo '# Backup user configs' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' if [ -d /home/$USERNAME/.config ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' echo "Backing up config files for $USERNAME"' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' if [ ! -d $USB_MOUNT/backup/config/$USERNAME ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' mkdir -p $USB_MOUNT/backup/config/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' backup_directory_to_usb /home/$USERNAME/.config config/$USERNAME' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo 'done' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo '' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
|
||||
echo '# Backup web sites' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo "if [ -d /etc/nginx ]; then" >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
echo ' echo "Backing up web settings"' >> /usr/bin/$BACKUP_SCRIPT_NAME
|
||||
|
@ -3467,6 +3482,33 @@ function create_restore_script {
|
|||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
|
||||
RESTORE_SUBDIR='home/'
|
||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
||||
RESTORE_SUBDIR='usb/backup/config/'
|
||||
fi
|
||||
echo 'if [ -d $USB_MOUNT/backup/config ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' for d in $USB_MOUNT/backup/config/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' echo "Restoring config files for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' restore_directory_from_usb /root/tempconfig config/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo -n " cp -r /root/tempconfig/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo '$USERNAME/.config /home/$USERNAME/' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' umount $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' rm -rf $USB_MOUNT' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' rm -rf /root/tempconfig' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' exit 664' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' rm -rf /root/tempconfig' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo ' done' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo 'fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
echo '' >> /usr/bin/$RESTORE_SCRIPT_NAME
|
||||
|
||||
RESTORE_SUBDIR='etc/'
|
||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
||||
RESTORE_SUBDIR='usb/backup/ssl/'
|
||||
|
@ -4501,6 +4543,21 @@ function backup_to_friends_servers {
|
|||
echo 'done' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
|
||||
echo '# Backup config files' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo 'for d in /home/*/ ; do' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' if [ -d /home/$USERNAME/.config ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' echo "Backing up config files for $USERNAME"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' if [ ! -d $SERVER_DIRECTORY/backup/config/$USERNAME ]; then' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' mkdir -p $SERVER_DIRECTORY/backup/config/$USERNAME' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo 'done' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo '' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
|
||||
echo '# Backup web sites' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo "if [ -d /etc/nginx ]; then" >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
echo ' echo "Backing up web settings"' >> /usr/bin/$BACKUP_TO_FRIENDS_SCRIPT_NAME
|
||||
|
@ -5197,6 +5254,31 @@ function restore_from_friend {
|
|||
echo 'done' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
|
||||
RESTORE_SUBDIR='home'
|
||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
||||
RESTORE_SUBDIR='remoterestore/backup/config'
|
||||
fi
|
||||
echo 'for d in $SERVER_DIRECTORY/backup/config/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $6}'"'"')' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' if [ -d $SERVER_DIRECTORY/backup/config/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' echo "Restoring config files for $USERNAME"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' restore_directory_from_friend /root/tempconfig config/$USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo -n " cp -r /root/tempconfig/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo '$USERNAME/.config /home/$USERNAME/' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' if [ ! "$?" = "0" ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' rm -rf /root/tempconfig' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' exit 664' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' rm -rf /root/tempconfig' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo 'done' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
echo '' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
|
||||
|
||||
RESTORE_SUBDIR='etc'
|
||||
if [[ $BACKUP_TYPE != 'obnam' ]]; then
|
||||
RESTORE_SUBDIR='remoterestore/backup/ssl'
|
||||
|
|
Loading…
Reference in New Issue