Check that any extra directories being backed up are not the same as existing ones
This commit is contained in:
parent
7fb07fc11d
commit
a8ae880ccd
|
@ -368,6 +368,9 @@ function backup_configuration {
|
||||||
fi
|
fi
|
||||||
cp -f $CONFIG_FILE /root/tempbackupconfig
|
cp -f $CONFIG_FILE /root/tempbackupconfig
|
||||||
cp -f $COMPLETION_FILE /root/tempbackupconfig
|
cp -f $COMPLETION_FILE /root/tempbackupconfig
|
||||||
|
if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||||
|
cp -f $BACKUP_EXTRA_DIRECTORIES /root/tempbackupconfig
|
||||||
|
fi
|
||||||
backup_directory_to_usb /root/tempbackupconfig config
|
backup_directory_to_usb /root/tempbackupconfig config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,6 +417,38 @@ function backup_mariadb {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function valid_backup_destination {
|
||||||
|
destination_dir="$1"
|
||||||
|
is_valid="yes"
|
||||||
|
|
||||||
|
if [[ "$destination_dir" == "hubzilla" || \
|
||||||
|
"$destination_dir" == "hubzilladata" || \
|
||||||
|
"$destination_dir" == "gogs" || \
|
||||||
|
"$destination_dir" == "gogsrepos" || \
|
||||||
|
"$destination_dir" == "gogsssh" || \
|
||||||
|
"$destination_dir" == "gnusocial" || \
|
||||||
|
"$destination_dir" == "gnusocialdata" || \
|
||||||
|
"$destination_dir" == "mariadb" || \
|
||||||
|
"$destination_dir" == "config" || \
|
||||||
|
"$destination_dir" == "letsencrypt" || \
|
||||||
|
"$destination_dir" == "wiki" || \
|
||||||
|
"$destination_dir" == "wiki2" || \
|
||||||
|
"$destination_dir" == "xmpp" || \
|
||||||
|
"$destination_dir" == "ipfs" || \
|
||||||
|
"$destination_dir" == "dlna" || \
|
||||||
|
"$destination_dir" == "tox" || \
|
||||||
|
"$destination_dir" == "ssl" || \
|
||||||
|
"$destination_dir" == "blog" || \
|
||||||
|
"$destination_dir" == "owncloud" || \
|
||||||
|
"$destination_dir" == "owncloud2" || \
|
||||||
|
"$destination_dir" == "ownclouddata" || \
|
||||||
|
"$destination_dir" == "mailinglist" ]]; then
|
||||||
|
is_valid="no"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $is_valid
|
||||||
|
}
|
||||||
|
|
||||||
function backup_extra_directories {
|
function backup_extra_directories {
|
||||||
if [ ! -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
if [ ! -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||||
return
|
return
|
||||||
|
@ -425,7 +460,12 @@ function backup_extra_directories {
|
||||||
backup_dir=$(echo "$backup_line" | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
backup_dir=$(echo "$backup_line" | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
if [ -d "$backup_dir" ]; then
|
if [ -d "$backup_dir" ]; then
|
||||||
destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
backup_directory_to_usb "$backup_dir" "$destination_dir"
|
if [[ $(valid_backup_destination "$destination_dir") == "yes" ]]; then
|
||||||
|
backup_directory_to_usb "$backup_dir" "$destination_dir"
|
||||||
|
else
|
||||||
|
echo $"WARNING: The backup directory $destination_dir is already used."
|
||||||
|
echo $"Choose a different destination name for backing up $backup_dir"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo $"WARNING: Directory $backup_dir does not exist"
|
echo $"WARNING: Directory $backup_dir does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -127,6 +127,9 @@ function backup_configuration {
|
||||||
fi
|
fi
|
||||||
cp -f $CONFIG_FILE /root/tempbackupconfig
|
cp -f $CONFIG_FILE /root/tempbackupconfig
|
||||||
cp -f $COMPLETION_FILE /root/tempbackupconfig
|
cp -f $COMPLETION_FILE /root/tempbackupconfig
|
||||||
|
if [ -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||||
|
cp -f $BACKUP_EXTRA_DIRECTORIES /root/tempbackupconfig
|
||||||
|
fi
|
||||||
backup_directory_to_friend /root/tempbackupconfig config
|
backup_directory_to_friend /root/tempbackupconfig config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,6 +442,38 @@ function disperse_key_shares {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function valid_backup_destination {
|
||||||
|
destination_dir="$1"
|
||||||
|
is_valid="yes"
|
||||||
|
|
||||||
|
if [[ "$destination_dir" == "hubzilla" || \
|
||||||
|
"$destination_dir" == "hubzilladata" || \
|
||||||
|
"$destination_dir" == "gogs" || \
|
||||||
|
"$destination_dir" == "gogsrepos" || \
|
||||||
|
"$destination_dir" == "gogsssh" || \
|
||||||
|
"$destination_dir" == "gnusocial" || \
|
||||||
|
"$destination_dir" == "gnusocialdata" || \
|
||||||
|
"$destination_dir" == "mariadb" || \
|
||||||
|
"$destination_dir" == "config" || \
|
||||||
|
"$destination_dir" == "letsencrypt" || \
|
||||||
|
"$destination_dir" == "wiki" || \
|
||||||
|
"$destination_dir" == "wiki2" || \
|
||||||
|
"$destination_dir" == "xmpp" || \
|
||||||
|
"$destination_dir" == "ipfs" || \
|
||||||
|
"$destination_dir" == "dlna" || \
|
||||||
|
"$destination_dir" == "tox" || \
|
||||||
|
"$destination_dir" == "ssl" || \
|
||||||
|
"$destination_dir" == "blog" || \
|
||||||
|
"$destination_dir" == "owncloud" || \
|
||||||
|
"$destination_dir" == "owncloud2" || \
|
||||||
|
"$destination_dir" == "ownclouddata" || \
|
||||||
|
"$destination_dir" == "mailinglist" ]]; then
|
||||||
|
is_valid="no"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $is_valid
|
||||||
|
}
|
||||||
|
|
||||||
function backup_extra_directories {
|
function backup_extra_directories {
|
||||||
if [ ! -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
if [ ! -f $BACKUP_EXTRA_DIRECTORIES ]; then
|
||||||
return
|
return
|
||||||
|
@ -450,7 +485,12 @@ function backup_extra_directories {
|
||||||
backup_dir=$(echo "$backup_line" | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
backup_dir=$(echo "$backup_line" | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
if [ -d "$backup_dir" ]; then
|
if [ -d "$backup_dir" ]; then
|
||||||
destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
destination_dir=$(echo "$backup_line" | awk -F ',' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
|
||||||
backup_directory_to_friend "$backup_dir" "$destination_dir"
|
if [[ $(valid_backup_destination "$destination_dir") == "yes" ]]; then
|
||||||
|
backup_directory_to_friend "$backup_dir" "$destination_dir"
|
||||||
|
else
|
||||||
|
echo $"WARNING: The backup directory $destination_dir is already used."
|
||||||
|
echo $"Choose a different destination name for backing up $backup_dir"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo $"WARNING: Directory $backup_dir does not exist"
|
echo $"WARNING: Directory $backup_dir does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -232,6 +232,7 @@ function restore_configuration {
|
||||||
if [ -d $USB_MOUNT/backup/config ]; then
|
if [ -d $USB_MOUNT/backup/config ]; then
|
||||||
echo $"Restoring configuration files"
|
echo $"Restoring configuration files"
|
||||||
restore_directory_from_usb /root/tempconfig config
|
restore_directory_from_usb /root/tempconfig config
|
||||||
|
|
||||||
cp -f /root/tempconfig/root/${PROJECT_NAME}.cfg $CONFIG_FILE
|
cp -f /root/tempconfig/root/${PROJECT_NAME}.cfg $CONFIG_FILE
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
unmount_drive
|
unmount_drive
|
||||||
|
@ -242,12 +243,23 @@ function restore_configuration {
|
||||||
# install according to the config file
|
# install according to the config file
|
||||||
freedombone -c $CONFIG_FILE
|
freedombone -c $CONFIG_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp -f /root/tempconfig/root/${PROJECT_NAME}-completed.txt $COMPLETION_FILE
|
cp -f /root/tempconfig/root/${PROJECT_NAME}-completed.txt $COMPLETION_FILE
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
unmount_drive
|
unmount_drive
|
||||||
rm -rf /root/tempconfig
|
rm -rf /root/tempconfig
|
||||||
exit 6382
|
exit 6382
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f /root/tempconfig${BACKUP_EXTRA_DIRECTORIES} ]; then
|
||||||
|
cp -f /root/tempconfig${BACKUP_EXTRA_DIRECTORIES} ${BACKUP_EXTRA_DIRECTORIES}
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
unmount_drive
|
||||||
|
rm -rf /root/tempconfig
|
||||||
|
exit 62121
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf /root/tempconfig
|
rm -rf /root/tempconfig
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,7 @@ function restore_configuration {
|
||||||
if [ -d $SERVER_DIRECTORY/backup/config ]; then
|
if [ -d $SERVER_DIRECTORY/backup/config ]; then
|
||||||
echo $"Restoring configuration files"
|
echo $"Restoring configuration files"
|
||||||
restore_directory_from_friend /root/tempconfig config
|
restore_directory_from_friend /root/tempconfig config
|
||||||
|
|
||||||
cp -f /root/tempconfig/root/${PROJECT_NAME}.cfg $CONFIG_FILE
|
cp -f /root/tempconfig/root/${PROJECT_NAME}.cfg $CONFIG_FILE
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
unmount_drive
|
unmount_drive
|
||||||
|
@ -152,12 +153,23 @@ function restore_configuration {
|
||||||
# install according to the config file
|
# install according to the config file
|
||||||
freedombone -c $CONFIG_FILE
|
freedombone -c $CONFIG_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp -f /root/tempconfig/root/${PROJECT_NAME}-completed.txt $COMPLETION_FILE
|
cp -f /root/tempconfig/root/${PROJECT_NAME}-completed.txt $COMPLETION_FILE
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
unmount_drive
|
unmount_drive
|
||||||
rm -rf /root/tempconfig
|
rm -rf /root/tempconfig
|
||||||
exit 7252
|
exit 7252
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f /root/tempconfig${BACKUP_EXTRA_DIRECTORIES} ]; then
|
||||||
|
cp -f /root/tempconfig${BACKUP_EXTRA_DIRECTORIES} ${BACKUP_EXTRA_DIRECTORIES}
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
unmount_drive
|
||||||
|
rm -rf /root/tempconfig
|
||||||
|
exit 62121
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf /root/tempconfig
|
rm -rf /root/tempconfig
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue