trexen
17th March 2011, 10:20
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 {} \;
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 {} \;