User Name
Password
AppleNova Forums » Apple Products »

Basic backup plan using Terminal, Script Editor, and iCal


Register Members List Calendar Search FAQ Posting Guidelines
Basic backup plan using Terminal, Script Editor, and iCal
Thread Tools
gusmore
New Member
 
Join Date: Feb 2005
 
2006-09-10, 12:03

Having little experience with Terminal, and an urge to wet my feet in it, I resolved to give myself the task of making a basic backup flow. Further, I wanted to get feedback from the community for improving what I've done.

To begin, I wanted to create a non-bootable backup on an external firewire drive connected to my iMac that would have daily updated copies of important folders from my Home folder. Due to space restrictions on the target firewire dirve, I chose to only copy "unreplaceable" files (i.e. I didn't backup up the system folder and applications, as I have hard copies of these). To do this, I read a little on rsync and first updated rsync (admittedly, I don't even know if this was necessary, but did it nonetheless) using <a href="http://www.lartmaker.nl/rsync/">these</a> instructions.

Next, I messed around with Terminal using the following command to backup a "test" copy of my Desktop to the firewire drive.

rsync --archive --delete --recursive --verbose --stats --progress ~/Desktop /Volumes/Narwhal/Backups/ 2>>~/rsyncErrDESKTOP.txt || echo -n

Playing around with this, I would add different files to the Desktop, change the name of files, and/or change the content of files. Then I would check in the backup copy to ensure the changes were properly transferred. I did this part as a sanity check. Having done this, I used a text editor to create a file that looked something like this (with "src" replaced by the directory that I wanted to backup):

rsync --archive --delete --recursive --verbose --stats --progress ~/src /Volumes/Narwhal/Backups/ 2>>~/rsyncErrDESKTOP.txt || echo -n

Thus, the final text file I made had a line similar to that above for each directory to be copied, with "src" replaced by the appropriate path name. I then copy and pasted this code into Terminal and confirmed that all the intended directories/files had been copied. The first time it runs, it's takes a while, but subsequent runs go quickly as the script should only copy new/modified files from the source to the target.

Ultimately, I wanted this to be something automated that ran daily. The solution I came across was to open Script Editor, and then type (for each directory):

do shell script "rsync --archive --delete --recursive --verbose --stats --progress ~/src /Volumes/Narwhal/Backups/ 2>>~/rsyncErrDESKTOP.txt || echo -n"

I saved this file as an application, and then set up an iCal alarm to run it nightly. I wouldn't be surprised if there's an easier way to do this, but it's what I have done, and after the initial setup and backup creation, it runs quickly. I tried other things (the Backup Folder action for Automator--much too slow) and find this simpler. I've read that there have been some problems with rsync in Tiger, but so far as I can tell this is working for my situation.
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools

« Previous Thread | Next Thread »

All times are GMT -5. The time now is 19:46.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova