I want a local copy, and a remote copy of my backups, without running the backup twice


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » DirectAdmin » Backup & Restore Process

I want a local copy, and a remote copy of my backups, without running the backup twiceLast Modified: Feb 1, 2019, 10:10 pm
Since the backup only allows for local or remote storage.. typically, two backup crons are needed.
This is less desirable as it doubles the overhead on the box for backups.

The solution is to only create 1 backup cron for ftp, and use the user_backup_post.sh script to copy the file locally before it's uploaded with ftp and deleted.

1) Create the following file

/usr/local/directadmin/scripts/custom/user_backup_post.sh


2) In that file, add the following code for :

#!/bin/sh

#############
#set this as needed
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;

Note, due to PIDs being added to the tmp backup path, the above requires a dot and a wildcard.
3) Chmod the script to 755:

chmod 755 /usr/local/directadmin/scripts/custom/user_backup_post.sh



 
Related Helpfiles
I want my locally created backups to contain a date in the filename

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST