Aner Backup script for Ispconfig 2

Discussion in 'Tips/Tricks/Mods' started by trexen, Mar 17, 2011.

  1. trexen

    trexen Member

    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: Mar 17, 2011

Share This Page