Backup and restore fin files if they exist
This commit is contained in:
parent
05d7d8dcd2
commit
0e247a521c
|
@ -289,6 +289,12 @@ function backup_users {
|
||||||
backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME
|
backup_directory_to_usb /home/$USERNAME/.ssh ssh/$USERNAME
|
||||||
fi
|
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
|
# Backup user configs
|
||||||
if [ -d /home/$USERNAME/.config ]; then
|
if [ -d /home/$USERNAME/.config ]; then
|
||||||
echo $"Backing up config files for $USERNAME"
|
echo $"Backing up config files for $USERNAME"
|
||||||
|
@ -506,28 +512,28 @@ function valid_backup_destination {
|
||||||
is_valid="yes"
|
is_valid="yes"
|
||||||
|
|
||||||
if [[ "$destination_dir" == "hubzilla" || \
|
if [[ "$destination_dir" == "hubzilla" || \
|
||||||
"$destination_dir" == "hubzilladata" || \
|
"$destination_dir" == "hubzilladata" || \
|
||||||
"$destination_dir" == "gogs" || \
|
"$destination_dir" == "gogs" || \
|
||||||
"$destination_dir" == "gogsrepos" || \
|
"$destination_dir" == "gogsrepos" || \
|
||||||
"$destination_dir" == "gogsssh" || \
|
"$destination_dir" == "gogsssh" || \
|
||||||
"$destination_dir" == "gnusocial" || \
|
"$destination_dir" == "gnusocial" || \
|
||||||
"$destination_dir" == "gnusocialdata" || \
|
"$destination_dir" == "gnusocialdata" || \
|
||||||
"$destination_dir" == "mariadb" || \
|
"$destination_dir" == "mariadb" || \
|
||||||
"$destination_dir" == "config" || \
|
"$destination_dir" == "config" || \
|
||||||
"$destination_dir" == "letsencrypt" || \
|
"$destination_dir" == "letsencrypt" || \
|
||||||
"$destination_dir" == "wiki" || \
|
"$destination_dir" == "wiki" || \
|
||||||
"$destination_dir" == "wiki2" || \
|
"$destination_dir" == "wiki2" || \
|
||||||
"$destination_dir" == "xmpp" || \
|
"$destination_dir" == "xmpp" || \
|
||||||
"$destination_dir" == "ipfs" || \
|
"$destination_dir" == "ipfs" || \
|
||||||
"$destination_dir" == "dlna" || \
|
"$destination_dir" == "dlna" || \
|
||||||
"$destination_dir" == "tox" || \
|
"$destination_dir" == "tox" || \
|
||||||
"$destination_dir" == "ssl" || \
|
"$destination_dir" == "ssl" || \
|
||||||
"$destination_dir" == "ttrss" || \
|
"$destination_dir" == "ttrss" || \
|
||||||
"$destination_dir" == "blog" || \
|
"$destination_dir" == "blog" || \
|
||||||
"$destination_dir" == "owncloud" || \
|
"$destination_dir" == "owncloud" || \
|
||||||
"$destination_dir" == "owncloud2" || \
|
"$destination_dir" == "owncloud2" || \
|
||||||
"$destination_dir" == "ownclouddata" || \
|
"$destination_dir" == "ownclouddata" || \
|
||||||
"$destination_dir" == "mailinglist" ]]; then
|
"$destination_dir" == "mailinglist" ]]; then
|
||||||
is_valid="no"
|
is_valid="no"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -208,6 +208,12 @@ function backup_users {
|
||||||
backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME
|
backup_directory_to_friend /home/$USERNAME/.config config/$USERNAME
|
||||||
fi
|
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
|
# local files
|
||||||
if [ -d /home/$USERNAME/.local ]; then
|
if [ -d /home/$USERNAME/.local ]; then
|
||||||
echo $"Backing up local files for $USERNAME"
|
echo $"Backing up local files for $USERNAME"
|
||||||
|
@ -507,7 +513,7 @@ function disperse_key_shares {
|
||||||
|
|
||||||
# copy the fragments directory to the remote server
|
# copy the fragments directory to the remote server
|
||||||
/usr/bin/sshpass -p "$REMOTE_PASSWORD" \
|
/usr/bin/sshpass -p "$REMOTE_PASSWORD" \
|
||||||
scp -r -P $REMOTE_SSH_PORT $temp_key_share_fragments $REMOTE_SERVER
|
scp -r -P $REMOTE_SSH_PORT $temp_key_share_fragments $REMOTE_SERVER
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
# Send a warning email
|
# Send a warning email
|
||||||
echo "Key share to $REMOTE_SERVER failed" | \
|
echo "Key share to $REMOTE_SERVER failed" | \
|
||||||
|
@ -531,27 +537,27 @@ function valid_backup_destination {
|
||||||
is_valid="yes"
|
is_valid="yes"
|
||||||
|
|
||||||
if [[ "$destination_dir" == "hubzilla" || \
|
if [[ "$destination_dir" == "hubzilla" || \
|
||||||
"$destination_dir" == "hubzilladata" || \
|
"$destination_dir" == "hubzilladata" || \
|
||||||
"$destination_dir" == "gogs" || \
|
"$destination_dir" == "gogs" || \
|
||||||
"$destination_dir" == "gogsrepos" || \
|
"$destination_dir" == "gogsrepos" || \
|
||||||
"$destination_dir" == "gogsssh" || \
|
"$destination_dir" == "gogsssh" || \
|
||||||
"$destination_dir" == "gnusocial" || \
|
"$destination_dir" == "gnusocial" || \
|
||||||
"$destination_dir" == "gnusocialdata" || \
|
"$destination_dir" == "gnusocialdata" || \
|
||||||
"$destination_dir" == "mariadb" || \
|
"$destination_dir" == "mariadb" || \
|
||||||
"$destination_dir" == "config" || \
|
"$destination_dir" == "config" || \
|
||||||
"$destination_dir" == "letsencrypt" || \
|
"$destination_dir" == "letsencrypt" || \
|
||||||
"$destination_dir" == "wiki" || \
|
"$destination_dir" == "wiki" || \
|
||||||
"$destination_dir" == "wiki2" || \
|
"$destination_dir" == "wiki2" || \
|
||||||
"$destination_dir" == "xmpp" || \
|
"$destination_dir" == "xmpp" || \
|
||||||
"$destination_dir" == "ipfs" || \
|
"$destination_dir" == "ipfs" || \
|
||||||
"$destination_dir" == "dlna" || \
|
"$destination_dir" == "dlna" || \
|
||||||
"$destination_dir" == "tox" || \
|
"$destination_dir" == "tox" || \
|
||||||
"$destination_dir" == "ssl" || \
|
"$destination_dir" == "ssl" || \
|
||||||
"$destination_dir" == "blog" || \
|
"$destination_dir" == "blog" || \
|
||||||
"$destination_dir" == "owncloud" || \
|
"$destination_dir" == "owncloud" || \
|
||||||
"$destination_dir" == "owncloud2" || \
|
"$destination_dir" == "owncloud2" || \
|
||||||
"$destination_dir" == "ownclouddata" || \
|
"$destination_dir" == "ownclouddata" || \
|
||||||
"$destination_dir" == "mailinglist" ]]; then
|
"$destination_dir" == "mailinglist" ]]; then
|
||||||
is_valid="no"
|
is_valid="no"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -601,6 +601,33 @@ function restore_user_config {
|
||||||
fi
|
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 {
|
function restore_user_local {
|
||||||
if [[ $RESTORE_APP != 'all' ]]; then
|
if [[ $RESTORE_APP != 'all' ]]; then
|
||||||
if [[ $RESTORE_APP != 'userlocal' ]]; then
|
if [[ $RESTORE_APP != 'userlocal' ]]; then
|
||||||
|
@ -1097,6 +1124,7 @@ restore_admin_readme
|
||||||
restore_ipfs
|
restore_ipfs
|
||||||
restore_user_ssh_keys
|
restore_user_ssh_keys
|
||||||
restore_user_config
|
restore_user_config
|
||||||
|
restore_user_fin
|
||||||
restore_user_local
|
restore_user_local
|
||||||
restore_certs
|
restore_certs
|
||||||
restore_personal_settings
|
restore_personal_settings
|
||||||
|
|
|
@ -481,6 +481,32 @@ function restore_user_config {
|
||||||
done
|
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 {
|
function restore_user_local {
|
||||||
if [[ $RESTORE_APP != 'all' ]]; then
|
if [[ $RESTORE_APP != 'all' ]]; then
|
||||||
if [[ $RESTORE_APP != 'userlocal' ]]; then
|
if [[ $RESTORE_APP != 'userlocal' ]]; then
|
||||||
|
@ -950,6 +976,7 @@ restore_admin_readme
|
||||||
restore_ipfs
|
restore_ipfs
|
||||||
restore_ssh_keys
|
restore_ssh_keys
|
||||||
restore_user_config
|
restore_user_config
|
||||||
|
restore_user_fin
|
||||||
restore_user_local
|
restore_user_local
|
||||||
restore_certs
|
restore_certs
|
||||||
restore_personal_settings
|
restore_personal_settings
|
||||||
|
|
Loading…
Reference in New Issue