Does your NAS have an rsync service set up? Some support it (e.g. ReadyNAS). If so, you can do something like this:
RSYNC_OPTS='-vaC --exclude ".DS_Store"'
/usr/bin/rsync $RSYNC_OPTS --exclude "build/" --exclude "dist/" --exclude "*.pyc" ~/code $DEST
/usr/bin/rsync $RSYNC_OPTS ~/Music $DEST
/usr/bin/rsync $RSYNC_OPTS ~/Pictures $DEST
/usr/bin/rsync $RSYNC_OPTS --exclude "Virtual Machines*" ~/Documents $DEST
You'll need to change DEST to the IP address of your NAS, and change paths and stuff to suit.
If you save that as, say,
~/bin/backup.sh (and be sure to do
chmod a+x ~/bin/backup.sh) then you can run it nighly using cron. Run
crontab -e and add this line:
0 0 * * * $HOME/bin/backup.sh > $HOME/logs/backup.log 2>&1
0 0 * * * means: run at midnight every day, every month. First column is minutes, so 3am is
0 3 * * *. This will write logs in
~/logs so make sure that directory exists, or put them somewhere else)
If your NAS doesn't support rsync as a service then I think it should work if you change the start to this:
mount_smbfs //user:email@example.com/backup /Volumes/backup
and at the end:
(if your share is open, you can leave off user and password)
If you want timestamped backups, you can experiment with the date command. e.g.
then access $DATE in your script.
If anything here isn't clear to you, just ask.