Archive for February, 2009

Backup newly modified files

My server backups over 20GB files everyday. It takes hours to tar those huge amount of files. I think this kind of stupid task is harmful to hard driver. One more stupid issue is that over 99% of files are not modified since last backup. So, here is the command to let me backup newly modified files only.

tar -zcvf /save/to/file.tar /filePath/* –newer-mtime ‘1 days ago’

You may want to change “1 days ago” to 2 days, or 5 days.

By the way, it’s better to do full backup monthly or bi-monthly. :)

  • Share/Save/Bookmark

Linux – delete files which modified time older than 7 days

find /filePath/* -mtime +7 -delete

or

find /filePath/* -mtime +7 -exec rm {} \;

Where “-mtime” parameter will look for file modified time older than “+7″ days. You may want to change “+7″ to longer days, for example “+30″ days, “+90″ days

“-exec” parameter allows you to call another command. The “{} \;” is required at the end.

  • Share/Save/Bookmark