archive your daily backups


Well-Known Member
Jul 2, 2004
If you are running WHM you may want to use a script like this to archive your daily backups - since WHM overwrites the previous daily resulting in no daily history.

You can do this several other ways than this script - but this works fine if you watch the disk space on your server and clean things up as needed.

I don't login here much - so I will maintain the script here on ModMySite:

If you have problems/questions - reach me on ModMySite as "smoge".

# ModMySite - Script Collection -
# [email protected]
# Backup Script For Archiving WHM Daily Backups to daily_archive directory
# Save this script in /root/scripts and call it
# chmod +x
# Create a daily_archive directory in whm backup directory
# Command line param is path to whm backup directory
# example is
# /root/scripts/ /backup/
# Set a cron job to run a few hours after your WHM backup runs
# Example cron job:
# 0 10 * * * /root/scripts/ /backup/
THISRUN=`date +%m_%d_%y_%H`
echo ------ Backing up ${1}cpbackup/daily on ${THISRUN} ------
echo Changing to ${1} directory.
cd ${1}
echo Directory change complete.
echo Creating archive of
echo ${1}cpbackup/daily to ${1}daily_archive directory.
echo Performing file compression.
tar -cvzf ${1}daily_archive/${THISRUN}_cpdaily.tar.gz ${1}cpbackup/daily &
echo Wating for file compression.
echo File compression done.
echo ---
echo Disk space report
echo This is overall system space not user specific.
df -h
echo ---
echo Listing ${1}daily_archive directory contents
ls ${1}daily_archive -l
echo ---
## Copying file to backup server
## scp ${1}daily_archive/${THISRUN}_cpdaily.tar.gz [email protected]:${THISRUN}_cpdaily.tar.gz
## echo ---
echo Done.