Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (4) </ 1 2 [3] 4 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: 7 day file backup script?, How to create 7 day file backup script?< Next Oldest | Next Newest >
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Jan. 22 2008,21:48 QUOTE

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.
Back to top
Profile PM 
Big_Pc_Man Offline





Group: Members
Posts: 86
Joined: July 2007
Posted: Jan. 22 2008,23:36 QUOTE

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.


--------------
Big_Pc_Man
Back to top
Profile PM 
lucky13 Offline





Group: Members
Posts: 1478
Joined: Feb. 2007
Posted: Jan. 22 2008,23:51 QUOTE

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.


--------------
"It felt kind of like having a pitbull terrier on my rear end."
-- meo (copyright(c)2008, all rights reserved)
Back to top
Profile PM WEB 
Big_Pc_Man Offline





Group: Members
Posts: 86
Joined: July 2007
Posted: Jan. 23 2008,00:18 QUOTE

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 {} \;


--------------
Big_Pc_Man
Back to top
Profile PM 
chaostic Offline





Group: Members
Posts: 328
Joined: Mar. 2005
Posted: Jan. 25 2008,07:19 QUOTE

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

Pray tell?
Back to top
Profile PM 
19 replies since Jan. 21 2008,18:51 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (4) </ 1 2 [3] 4 >/
reply to topic new topic new poll
Quick Reply: 7 day file backup script?

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code