everything! including the rsync

i’m not sure what psync is and whether i should use that instead… but that backup script was reeeal easy.

y’all ready for this?

rsync -avz --delete /Users /Volumes/archive/_backup

rsync: calls up the rsync command. it’s like cp (copy) but it only copies the changes so you’re not doing a 30 gig copy every night.
-a = archive mode, meaning it preserves permissions, times, owners, groups, and symlinks
-v = verbose… it tells you what it’s doing as it does it. which i guess is useless in a shell script, eh? but handy for when i want to call it up by hand.
-z = compress data changes… not sure if it makes a difference considering this is going just from one mounted drive to another, but it does hurt right?
–delete = it, uh.. deletes. :p it deletes files from the target (where the back up will go) if they no longer exist in the source (what you’re backing up)

then i choose what to back up (the Users directory) and it copies it to the target (an external drive.) without a trailing slash (i.e. /Users vs /Users/ ) it copies the Users DIRECTORY into /_backup/ instead of copying just the CONTENTS of the Users directory. most hard drives mounted on your system will be in /Volumes/

you can do this all through os x’s terminal. by default you should be in your home directory, so this command:

pico _backup.sh

starts the pico editor… just type in the rsync command previously mentioned (making changes of course to reflect your needs). then hit ctrl+x to quit it, it’ll ask you to save, so obviously… save. it’ll create a file called _backup.sh in your home directory.

if you need to change where the file goes you can use this (minus quotes): “/whatever/directory/_backup.sh” instead. just remember “/” at the beginning means to start from the root of your system. like a file on your desktop would be /Users/yourusername/Desktop/filename.ext

chmod +x _backup.sh

that allows it to be executable… you can also use the full path like i mentioned earlier.
and this:

sudo crontab -e

installs a cronjob so it’ll run as root. i dont know if installing it into my user crontab would keep it from running (probably), but i figure it’d be better this way. once you’re editing the crontab, add:

33 3 * * * /Users/username/_backup.sh

that calls up the shell script i wrote every 3:33 AM.

you might be using the VIM editor… hit the i key to start inserting text. to escape from insert mode hit the esc key. then type “:wq” (no quotes obviously) to write the file and quit the editor. that should install the new crontab :)
you can move that script to where, just so long as you make sure the cronjob points to the right place

anyway, so this thing runs nightly now. i’m reconsidering doing a full hard drive back up. so i’ll have a completely bootable back up instead of just the documents. hmm… /me ponders. i guess i should do it… *sigh*

One Comment

  1. Posted September 23, 2004 at 4:43 pm | Permalink

    i guess it would be easily understandable to someone who knows what you’re talking about in the first place…
    psync, rsync, script.. all foreign to me…

    but it’s ok. i still love you.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*
Copyright © 2007 prototypecreative.com. All rights reserved.