Backup type

This commit is contained in:
Bob Mottram 2015-09-13 14:14:10 +01:00
parent 04d392eb44
commit 179b3d1adb
1 changed files with 22 additions and 18 deletions

View File

@ -219,6 +219,9 @@ UPGRADE_SCRIPT_NAME="freedombone-upgrade"
# name of a script which keeps running processes going even if they crash
WATCHDOG_SCRIPT_NAME="keepon"
# the type of backup system used
BACKUP_TYPE='rsync'
# Name of a script used to create a backup of the system on usb drive
BACKUP_SCRIPT_NAME="backup"
@ -776,6 +779,9 @@ function read_configuration {
fi
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "BACKUP_TYPE" $CONFIGURATION_FILE; then
BACKUP_TYPE=$(grep "BACKUP_TYPE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if grep -q "TRACKER_PORT" $CONFIGURATION_FILE; then
TRACKER_PORT=$(grep "TRACKER_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
@ -2409,25 +2415,23 @@ function get_mariadb_owncloud_admin_password {
fi
}
BACKUP_TYPE='rsync'
function backup_directory_to_usb {
if [[ $BACKUP_TYPE == 'rsync' ]]; then
echo "rsyncrypto -v -r ${1} $USB_MOUNT/backup/${2} $USB_MOUNT/backup/${2}.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ ${1} == "/root/temp"* ]]; then
echo " shred -zu ${1}/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
echo ' exit 853' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ ${1} == "/root/temp"* ]]; then
echo "shred -zu ${1}/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "rm -rf ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
fi
if [[ $BACKUP_TYPE == 'rsync' ]]; then
echo "rsyncrypto -v -r ${1} $USB_MOUNT/backup/${2} $USB_MOUNT/backup/${2}.keys $BACKUP_CERTIFICATE" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'if [ ! "$?" = "0" ]; then' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " umount $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf $USB_MOUNT" >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ ${1} == "/root/temp"* ]]; then
echo " shred -zu ${1}/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo " rm -rf ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
echo ' exit 853' >> /usr/bin/$BACKUP_SCRIPT_NAME
echo 'fi' >> /usr/bin/$BACKUP_SCRIPT_NAME
if [[ ${1} == "/root/temp"* ]]; then
echo "shred -zu ${1}/*" >> /usr/bin/$BACKUP_SCRIPT_NAME
echo "rm -rf ${1}" >> /usr/bin/$BACKUP_SCRIPT_NAME
fi
fi
}
# For rsyncrypto usage see http://archive09.linux.com/feature/125322