{"id":52,"date":"2008-12-15T23:51:14","date_gmt":"2008-12-16T04:51:14","guid":{"rendered":"http:\/\/www.ryanburns.net\/blog\/?p=52"},"modified":"2008-12-20T19:45:15","modified_gmt":"2008-12-21T00:45:15","slug":"easy-backups-in-os-x","status":"publish","type":"post","link":"https:\/\/www.ryanburns.net\/blog\/?p=52","title":{"rendered":"Easy backups in OS X"},"content":{"rendered":"<p>I&#8217;ve settled on the killer combination for easy backups to a NAS on OS X, and it involves installing no software.\u00a0 It&#8217;s a combination of rsync, and scheduling with launchd.<\/p>\n<p>The first step is getting your rsync command working.\u00a0 I like it because it allows you to maintain a mirror of your files on the remote drive, and only copies over files that have changed when you run it.\u00a0 Being a built-in command, it&#8217;s also a lot sleeker than installing a GUIed app of questionable speed.  I mirror various key folders like this:<\/p>\n<pre>rsync -aSv --delete --progress ~\/Pictures\/ \/Volumes\/MACSHARE\/rsync\/Pictures &gt; ~\/scripts\/logs\/pictures.txt<\/pre>\n<p>There&#8217;s a number of options you can look at through the rsync man pages.  I store my rsync commands in a file called backup.shIn order to Automate this process, you can set up a launchd task.  Launchd replaced a lot of unix apps like cron on more recent OS X releases.  You need to set up a plist file that points to your backup script and tells it how often to run, and store it in ~\/Library\/LaunchAgents\/.  Here is the file I use (you can call it something like com.backup.plist):<\/p>\n<pre lang=\"XML\">\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<!DOCTYPE plist PUBLIC \"-\/\/Apple\/\/DTD PLIST 1.0\/\/EN\" \"http:\/\/www.apple.com\/DTDs\/PropertyList-1.0.dtd\">\r\n<plist version=\"1.0\">\r\n<dict>\r\n        <key>Label<\/key>\r\n        <string>ryan.backup.script<\/string>\r\n        <key>LowPriorityIO<\/key>\r\n        <true\/>\r\n\t<key>ProgramArguments<\/key>\r\n\t\t<array>\r\n\t\t\t<string>\/Users\/ryan\/Scripts\/backup.sh<\/string>\r\n\t\t<\/array>\r\n        <key>StartCalendarInterval<\/key>\r\n        <dict>\r\n        \t<key>Hour<\/key>\r\n\t\t<integer>2<\/integer>\r\n\t\t<key>Minute<\/key>\r\n\t\t<integer>0<\/integer>\r\n        <\/dict>\r\n<\/dict>\r\n<\/plist>\r\n<\/pre>\n<p>You can look at the Apple <a href=\"http:\/\/developer.apple.com\/documentation\/Darwin\/Reference\/ManPages\/man5\/launchd.plist.5.html#\/\/apple_ref\/doc\/man\/5\/launchd.plist\">man pages for launchd<\/a> to determine what other arguments you can use.  This one is set to run at 2am.  You can also do some cool things such as running a script when a watched directory changes.Once you have your plist file, you have to register it with launchd.\u00a0 In the LaunchAgents directory at the terminal, you can type <code>launchctl load com.backup.plist <\/code> A trick I used to make sure the scheduling was working, is to point to an alternative script (test.sh) containing <code> say hello<\/code>.  I set the schedule a few minutes ahead and made sure the speakers were on to hear it say &#8220;hello&#8221;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve settled on the killer combination for easy backups to a NAS on OS X, and it involves installing no software.\u00a0 It&#8217;s a combination of rsync, and scheduling with launchd. The first step is getting your rsync command working.\u00a0 I like it because it allows you to maintain a mirror of your files on the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=52"}],"version-history":[{"count":2,"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":54,"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions\/54"}],"wp:attachment":[{"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ryanburns.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}