Hi,
I am wanting to preform an incremental admin backup locally and by ftp.
I am looking at the following for my backup regimen:
I want my locally created backups to contain a date in the filename:
http://help.directadmin.com/item.php?id=454
I want a local copy, and a remote copy of my backups, without running the backup twice:
http://help.directadmin.com/item.php?id=511
Will running these two together, in the same user_backup_post.sh file, have any conflict?
Basically, will it rename the backup then copy from tmp to the local admin_backups folder before sending it to the remote server?
I'm thinking the conflict will be where it has two different required paths. Should I be renaming it in the tmp location first before copying to the local admin_backups then sending renamed files to remote location with ftp?
the script:
I am wanting to preform an incremental admin backup locally and by ftp.
I am looking at the following for my backup regimen:
I want my locally created backups to contain a date in the filename:
http://help.directadmin.com/item.php?id=454
I want a local copy, and a remote copy of my backups, without running the backup twice:
http://help.directadmin.com/item.php?id=511
Will running these two together, in the same user_backup_post.sh file, have any conflict?
Basically, will it rename the backup then copy from tmp to the local admin_backups folder before sending it to the remote server?
I'm thinking the conflict will be where it has two different required paths. Should I be renaming it in the tmp location first before copying to the local admin_backups then sending renamed files to remote location with ftp?
the script:
Code:
#!/bin/sh
#set this as needed
RESELLER=admin
BACKUP_PATH=`echo $file | cut -d/ -f1,2,3,4`
REQUIRED_PATH=/home/$RESELLER/admin_backups
if [ "$BACKUP_PATH" = "$REQUIRED_PATH" ]; then
if [ "`echo $file | cut -d. -f4,5`" = "tar.gz" ]; then
NEW_FILE=`echo $file | cut -d. -f1,2,3`.`date +%F-%H-%M`.tar.gz
if [ -s "$file" ] && [ ! -e "$NEW_FILE" ]; then
mv $file $NEW_FILE
fi
fi
fi
RESELLER=admin
#where do you want to save the local copy?
SAVE_PATH=/home/$RESELLER/admin_backups
#############
BACKUP_PATH=`echo $file | cut -d/ -f1,2,3,4`
REQUIRED_PATH=/home/tmp/$RESELLER
if [ "$BACKUP_PATH" = "$REQUIRED_PATH" ]; then
NEW_FILE=${SAVE_PATH}/`echo $file | cut -d/ -f5`
cp -fp $file $NEW_FILE
fi
exit 0;