You are not logged in.
I know I should probably know how to do this but for some reason I can't think of the command. What I basically want to do is take one folder, and make a copy of it on a set schedule each week.
Basically I want to take the contents of ~/writings and copy it to /mnt/Backup/writings/date each week, but the "date" folder has to be the date that it's backing up the files. For example, if the script ran today I would want it to take the contents of ~/writings and copy the contents of it to /mnt/Backup/2010-09-16. The next time it runs would be a different date. Does this make sense?
I do this manually right now but sometimes I forget to back up this folder and today I lost some of my writing (although a trivial amount) and I could have avoided it should I have had a backup.
Further, it would be pretty cool if it would automatically delete folders that have a date older than six months, but I don't know how to do that either. I feel that I should know this and would probably shoot myself once I see the command but I'm not coming up with anything...
Last edited by jlacroix (2010-09-19 21:53:21)
Offline
How about a cron job?
'man date' will tell you what does e.g.
$(date +"%Y%m%d-%H%M%S").tar
mean.
'man find' will tell you how to find files 'older than ...'.
Last edited by karol (2010-09-16 17:22:48)
Offline
i'd also suggest a cron job. maybe to run an {r}sync script that checks if -d /mnt/Backup/(date '+%Y-%m-%d') exists and if not, create it then sync. not sure about the old directory rotation. haven't tested this: find $1 -type d -mtime +$2 -exec rm -r {} \;
edit: ah, edit! too slow, then. :{
Last edited by milomouse (2010-09-16 17:23:50)
Offline
May backup scheme rsyncs my documents to ~/backup/docs (so i don't copy the files that didn't change since the last time) and then I create tar archives with the current date / time. Compress them and e-mail them to my gmail account.
Offline
set up a cron job. The command is cp --preserve -r /the/full/path/to/writings /mnt/Backup/Writings/$(date +%y.%m.%d)
This assumes you want to retain ownership and permission information.
The full path is required because it runs as root.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
set up a cron job. The command is cp --preserve -r /the/full/path/to/writings /mnt/Backup/Writings/$(date +%y.%m.%d)
This assumes you want to retain ownership and permission information.
The full path is required because it runs as root.
Will this create the folder or exit because there's none?
Offline
it wont create them. i'd almost suggest using the "install" command. something like:
install --compare -D /full/path/writings/* /mnt/Backup/$(date '+%Y-%m-%d')
or something similar.
edit: accidentally added leading '-'
edit2: actually i don't think that will work either. :{
Last edited by milomouse (2010-09-16 17:34:50)
Offline
It should create the new date directory. It depends on the existence of /mnt/Backuo/Writings.
In a full blown script, I'd check that the volume is mounted and that Writings exists. If not, an email could be sent to the interested parties notifying them that the backup did not occur. If it is okay to fail, this is less important. The error messages would be logged by cron.
I could be wrong. I have not tried this :-)
Last edited by ewaller (2010-09-16 17:36:27)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Thanks guys, I'm going to play with this when I get home.
Offline
It should create the new date directory. It depends on the existence of /mnt/Backuo/Writings.
In a full blown script, I'd check that the volume is mounted and that Writings exists. If not, an email could be sent to the interested parties notifying them that the backup did not occur. If it is okay to fail, this is less important. The error messages would be logged by cron.I could be wrong. I have not tried this :-)
Actually, emailing me when that fails would probably be the next step. Right now I'm just focusing on getting it to work, and then I could set up an email job, but I've always had problems doing that as the computer is not on a FQDN.
Offline
http://wiki.archlinux.org/index.php/Backup <- full-blown backup apps
http://pbrisbin.com/pages/scripts.html? … bin/backup <- a nice script you can "borrow"
Last edited by karol (2010-09-16 17:41:24)
Offline
p.brisbin has a script for everything. :} here's what i use, although pretty personalized and derived from simple examples. http://github.com/milomouse/code/blob/master/shell/zinc
edit: just posting as another example. follow karol's links preferably.
Last edited by milomouse (2010-09-16 17:43:38)
Offline
http://wiki.archlinux.org/index.php/Backup <- full-blown backup apps
http://pbrisbin.com/pages/scripts.html? … bin/backup <- a nice script you can "borrow"
The thing is I already have a backup solution in place (Unison) but it synchronizes two folders, and the Writings folder is the one folder that I want to have a weekly history of. Those scripts may still be useful though.
Last edited by jlacroix (2010-09-16 17:44:06)
Offline
Thanks everyone, the solution from ewaller worked for me.
Offline