Tag: tar backup

  • Backup with tar

    To backup a site using tar, i created a shell script.

    mkdir /usr/serverok/
    vi /usr/serverok/backup-daily.sh
    

    With following content

    #!/bin/bash
    
    /bin/tar zcvhf /backup/daily/backup.tgz /home/serverok.in/public_html/
    

    For weekly backup

    cp /usr/serverok/backup-daily.sh /usr/serverok/backup-weekly.sh
    sed -i 's/daily/weekly/g' /usr/serverok/backup-weekly.sh 
    

    Make it executable

    chmod 755 /usr/serverok/backup-daily.sh
    chmod 755 /usr/serverok/backup-weekly.sh
    

    Create backup folders

    mkdir  -p /backup/weekly
    mkdir  -p /backup/daily
    

    Set cronjob

    crontab -e
    

    Add

    @weekly /usr/serverok/backup-weekly.sh  > /var/log/backup-weekly.log 2>&1
    @daily /usr/serverok/backup-daily.sh  > /var/log/backup-daily.log 2>&1
    

    See backup