{"id":1678,"date":"2006-08-20T23:41:23","date_gmt":"2006-08-20T22:41:23","guid":{"rendered":"http:\/\/www.chipwreck.de\/blog\/?p=1678"},"modified":"2016-12-31T02:05:10","modified_gmt":"2016-12-31T01:05:10","slug":"backup-script-using-rsyncx","status":"publish","type":"post","link":"https:\/\/www.chipwreck.de\/blog\/2006\/08\/20\/backup-script-using-rsyncx\/","title":{"rendered":"Backup Script using rsyncx"},"content":{"rendered":"<p>The Code is below, should be self-explanatory.<\/p>\n<p>More information found here:<br \/>\n<a href=\"http:\/\/blog.plasticsfuture.org\/2006\/03\/05\/the-state-of-backup-and-%20cloning-tools-under-mac-os-x\/\" target=\"_blank\">blog.plasticsfuture.org \u00bb<\/a><\/p>\n<p><!--more--><\/p>\n<pre lang=\"bash\">rsync \u2013 backup.sh\r\n\r\n#!\/bin\/bash\r\n# backup-script for rsync\/osx\r\n#\r\n# version 1.12\r\n# Mario Fischer ich@mariofischer.name\r\n#\r\n\r\n#\r\n# ----- Set Default Parameters -----\r\n#\r\n\r\n# folders to backup..\r\nsrc_folders=\"\/Users\/mario\/ \/Applications \/Library\"\r\n\r\n# backup-target\r\ndest_folder=\"\/Volumes\/backup\/\"\r\n\r\n# location of hfs-enabled rsync-command\r\nrsync_cmd=\"\/opt\/local\/bin\/rsync\"\r\n\r\n# excluded folders, separate with space, terminate with \"\/\"\r\nexclude_folders=\"Safari\/Icons\/ Caches\/ .Trash\/\"\r\n\r\n# rsync options\r\nrsync_options=\"--dry-run --relative -a --eahfs --delete --force \" # --force --delete --delete-excluded\"\r\n\r\n#\r\n# ----- Check if params are reasonable -----\r\n#\r\n\r\nif [[ $rsync_cmd == \"\" ]]; then\r\necho \"no command given\"\r\nexit 1\r\nfi\r\nif [[ ! -x $rsync_cmd ]]; then\r\necho \"$rsync_cmd is not executable\"\r\nexit 1\r\nfi\r\nif [[ ! -d $dest_folder ]]; then\r\necho \"$dest_folder is not a directory\"\r\nexit 1\r\nfi\r\nif [[ ! -w $dest_folder ]]; then\r\necho \"$dest_folder is not writable\"\r\nexit 1\r\nfi\r\n\r\n# build exclude-options\r\nfor path in $exclude_folders; do\r\nexc_options=\"$exc_options--exclude \\\"$path\\\" \"\r\ndone\r\n\r\n# build cmdline\r\ncmd=\"sudo $rsync_cmd $rsync_options $additional_options $exc_options\"\r\n\r\n#\r\n# ----- do rsync -----\r\n#\r\n\r\nfor path in $src_folders; do\r\ncmd_here=\"$cmd $path $dest_folder\"\r\necho `date`\" &gt;&gt; calling rsync for $path \"\r\neval $cmd_here\r\necho \" \"\r\ndone\r\n\r\necho \"backup complete.\"\r\nexit 0\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Code is below, should be self-explanatory. More information found here: blog.plasticsfuture.org \u00bb<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[78,7],"class_list":["post-1678","post","type-post","status-publish","format-standard","hentry","category-osx","tag-osx","tag-shell"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paPEN-r4","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.chipwreck.de\/blog\/wp-json\/wp\/v2\/posts\/1678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.chipwreck.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.chipwreck.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.chipwreck.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.chipwreck.de\/blog\/wp-json\/wp\/v2\/comments?post=1678"}],"version-history":[{"count":0,"href":"https:\/\/www.chipwreck.de\/blog\/wp-json\/wp\/v2\/posts\/1678\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.chipwreck.de\/blog\/wp-json\/wp\/v2\/media?parent=1678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.chipwreck.de\/blog\/wp-json\/wp\/v2\/categories?post=1678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.chipwreck.de\/blog\/wp-json\/wp\/v2\/tags?post=1678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}