Find the answer to your Linux question:
Results 1 to 4 of 4
Hi all, I have already created a backup scrip that currently is running, however i would like let the task run it repeatedly by overwriting the data for previous week. ...
  1. #1
    Just Joined!
    Join Date
    Sep 2010
    Posts
    7

    Weekly repeat backup

    Hi all,

    I have already created a backup scrip that currently is running, however i would like let the task run it repeatedly by overwriting the data for previous week.

    Here are the scripts i'm using to run it:

    #! /bin/bash
    echo Backup Started `date` >> ~/backuplog
    mkdir /mnt/usbdrive/backups/`date +%Y%m%d`
    tar -czf /mnt/usbdrive/backups/`date +%Y%m%d`/data.tar.gz /data
    echo Backup Completed `date` >> ~/backuplog

    What are the add in that i need put into so the backup can repeat automatically?

    Thanks in advance

  2. #2
    Linux Guru gogalthorp's Avatar
    Join Date
    Oct 2006
    Location
    West (by God) Virginia
    Posts
    3,105
    You usually would set this up in cron to run this script at set times

  3. #3
    Just Joined!
    Join Date
    Sep 2010
    Posts
    7
    Yes, i scheduled it using cron

    However, i need to make it will overwrite the data weekly so i don't need to delete those files when the HDD is full.

    Is there any command i should add in?

  4. #4
    Just Joined!
    Join Date
    Dec 2009
    Posts
    1
    ....overwrite the data weekly so i don't need to delete those files when the HDD is full.

    1 option: you can use the 'find' command to look for files older than the curent day, I delete my backup files that are older than 6 days, and execute a 'rm' command.
    Code:
    find $backupdir -mtime +6 \( -name "whateveritmaybe" \) -print -exec rm {} \;
    A quick look at 'man find' will clear things a bit on that one liner.

    You can put that in a script on the weekly cron.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...