archive your daily backups

smoge

Well-Known Member
Jul 2, 2004
52
0
156
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:
http://www.modmysite.com/showthread.php?p=17657

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

Code:
#!/bin/bash
# ModMySite - Script Collection - archive_whm_daily.sh
# http://www.modmysite.com/showthread.php?p=17657
# [email protected]
# Backup Script For Archiving WHM Daily Backups to daily_archive directory
# Save this script in /root/scripts and call it archive_whm_daily.sh
# chmod +x archive_whm_daily.sh
# Create a daily_archive directory in whm backup directory
# Command line param is path to whm backup directory
# example is
# /root/scripts/backup_whm_daily.sh /backup/
# Set a cron job to run a few hours after your WHM backup runs
# Example cron job:
# 0 10 * * * /root/scripts/archive_whm_daily.sh /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.
wait
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.