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 >
Big_Pc_Man Offline





Group: Members
Posts: 86
Joined: July 2007
Posted: Jan. 22 2008,19:39 QUOTE

Thanks to all for the ideas.

Specifically what I'm doing is once a day creating a zip file of a critical directory and then copying it over to a dedicated usb stick. I simply want to automate this process and maintain a week long archive.

It's been a long time since I wrote scripts so I'm quite rusty at interpreting what the offered examples do.  I'll start studying up but would appreciate a little more explanation as to how each example works. For instance I have no idea why the OSX script would be bad.


--------------
Big_Pc_Man
Back to top
Profile PM 
^thehatsrule^ Offline





Group: Members
Posts: 3275
Joined: July 2006
Posted: Jan. 22 2008,19:53 QUOTE

If I get what you mean, it can be something like (using easy-to-read/change variables to see what it does):
Code Sample
folder_to_backup="/path/to/myfolder"
backup_name="mybackupname"
backup_location="/path/to/mybackuplocation"

backup_name="${backup_name}-`date +%a`.tar.gz"
cd "$backup_location"
rm -f "$backup_name"
tar zcvf "$backup_name" "$folder_to_backup"
Basically this will use filenames based on the day of the week... and will remove last week's if it exists before making a .tar.gz out of your specified folder.

Quote
For instance I have no idea why the OSX script would be bad.
At first glance, I think it was a reference to the if-statements.

fyi: this seems more of a scripting thread than a mydsl one...?
Back to top
Profile PM 
lucky13 Offline





Group: Members
Posts: 1478
Joined: Feb. 2007
Posted: Jan. 22 2008,20:43 QUOTE

Quote
I'm trying to backup a file once a day such that I have a weekly archive of the file...

is different from...
Quote
creating a zip file of a critical directory and then copying it over to a dedicated usb stick.


anyway...
Quote
I'm quite rusty at interpreting what the offered examples do.

And I thought I was too pedantic with my explanation of a rather simple script. I was under the impression from the first quote above that you wanted to create something like a weekly log of a particular file. Let me know what's unclear about either script I offered and I'll help knock some of your rust off.

^thehatsrule^ is right about the if statements and that this is in the wrong section and belongs in scripting.


--------------
"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. 22 2008,20:47 QUOTE

Thanks for the script ^thehatsrule^.

OK, I deleted my previous response because it finally sank in how the script works. It just makes the name of the backup file whatever it is plus the day of the week and if it already exists deletes it. The backups will roll around the week with each day in the archive until the same day arrives a week later. Nice and simple. I must be a little thick today.


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





Group: Members
Posts: 86
Joined: July 2007
Posted: Jan. 22 2008,20:54 QUOTE

I do understand lucky13's scripts, I was referring to the OSX one. Thank you lucky13 for the examples.

--------------
Big_Pc_Man
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