View Single Post
  #1  
Old 17th March 2011, 11:20
trexen trexen is offline
Senior Member
 
Join Date: Jun 2008
Location: Stockholm
Posts: 169
Thanks: 15
Thanked 3 Times in 2 Posts
Default Aner Backup script for Ispconfig 2

I just whant to share my backupscript.
it backup all dir under /var/www/ to separate tar files whit todays date.

--------------------------------------------
#!/bin/bash
work_dir="/var/www/"
bkup_dir="/mnt/backup/www/"
date=`date +%Y%m%d`

cd $work_dir
for file in `\ls -1dt web*`
do
echo \"$file\";
tar pczf $bkup_dir$file-$date.tgz $work_dir$file/
done
----------------------------------------------------

enjoy
regards
Marcus


if you like to auto remove backup after 30 days add this into the script:

days_to_keep=30
#remove old files, older than 30 days
echo "Deleting old archives from $bkup_dir"
find $bkup_dirweb* -type f -mtime +$days_to_keep -exec rm {} \;

Last edited by trexen; 17th March 2011 at 16:39. Reason: script updated
Reply With Quote
Sponsored Links