Apps :: 7 day file backup script?



EDIT: heh, I just made a nice post with quotes, and then just saw what happened :P  I'll leave this part in:

Obviously, this method only works if you run this daily (as you indicated earlier).

On "find":
Quote
I found this little piece of code that locates a back in time date. Would this be a better approach to delete the week old file?
Sure, you could adapt that and use it instead... which would remedy the above exception.  Make sure you don't use that directory for anything else though.  If you decide to do this, you may as well use a full date format too.

Alright, it's looks like a simple and interval flexible approach would be:

Code Sample
tar zcvf /archive_folder/"my_backup_file_name-`date`"  /folder_to_be_backed_up
find /archive_folder/* -mtime +7 -exec rm {} \;


Where 7 could be changed to any number of days and the cron job could be run on any multiple day interval including daily. I'm not sure what the date % options need to be to get an acceptable file name format with a complete date.

Quote
. I'm not sure what the date % options need to be to get an acceptable file name format with a complete date.

Go back and look at my scripts. And what I wrote beneath them.

Looks like %Y%j will give me 2008022 where the 022 will be the day of the year. That will work fine for my needs. So I end up with:

Code Sample
tar zcf /archive_folder/"my_backup_file_name-`date +%Y%j`".tar.gz  /folder_to_be_backed_up
find /archive_folder/* -mtime +7 -exec rm {} \;

Quote (mikshaw @ Jan. 22 2008,07:37)
That OSX script is terrible =o)

Pray tell?
Next Page...
original here.