{"id":248,"date":"2008-08-23T22:58:38","date_gmt":"2008-08-24T06:58:38","guid":{"rendered":"http:\/\/mike.peay.us\/blog\/?p=248"},"modified":"2009-09-19T22:12:58","modified_gmt":"2009-09-20T06:12:58","slug":"i-learned-all-about-time-machine-so-you-dont-have-to","status":"publish","type":"post","link":"https:\/\/mike.peay.us\/blog\/archives\/248","title":{"rendered":"I learned all about Time (Machine) so you don&#8217;t have to"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft\" title=\"Time Machine\" src=\"http:\/\/37prime.files.wordpress.com\/2008\/03\/timemachine.png\" alt=\"\" width=\"154\" height=\"154\" \/>I&#8217;ve been learning a lot about the <a href=\"http:\/\/www.apple.com\/macosx\/features\/timemachine.html\" target=\"_blank\">Time Machine<\/a> feature of Apple&#8217;s OS X 10.5 (Leopard) and wanted to take the time to share my experience. In a nutshell, Time Machine watches the files that get modified on your system and copies them to a secondary hard drive or network volume so that you have automatic backups available for anything that was deleted or modified.<\/p>\n<p>It is a very nice user experience and it takes a lot of the work out of making backups. Of course, by taking work out Apple is really just making decisions for the majority of users and for most users, that decision is quite acceptable. I&#8217;m not most users. Fortunately, Apple directly or indirectly provides methods for changing the behavior of much of the OS and Time Machine is no exception. Here are many of the things that I&#8217;ve gathered over the last few months that might benefit you if you want to get more out of your experience.<\/p>\n<p><strong>Overview<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright\" src=\"http:\/\/atmac.org\/wp-content\/uploads\/timemachine-disk-150x150.png\" alt=\"\" width=\"150\" height=\"150\" \/>I won&#8217;t go into too much detail as I&#8217;m going to presume you&#8217;ve already used Time Machine and are familiar with how it works. Generally, it performs a backup of your system every hour to an external drive. It is\u00a0efficient\u00a0in that only the modified\u00a0files are copied. Hourly copies are kept for for 24 hours, daily copies for a month, and weekly copies until the destination drive fills up. You are free to put other data on that Time Machine disk, but it will eventually consume all available space.<\/p>\n<p>Space is pretty efficiently used in that a file is copied only if it has changed but ineffecient in that a small change to a large file results in the entire file being backed up again. This can be a problem if the file really is big and changes frequently. This is the case with the virtual hard disk used for a virtual machine under <a href=\"http:\/\/www.vmware.com\/products\/fusion\/\" target=\"_blank\">VMware Fusion<\/a> or <a href=\"http:\/\/www.parallels.com\/en\/desktop\/\">Parallels Desktop<\/a>.<\/p>\n<p><strong>Backing-up to a network volume<\/strong><\/p>\n<p>Any self-respecting geek has more than one computer in his or her home. Often times, you are using a laptop and have a dedicated computer with more storage sitting by your TV or in the den, closet, or garage. Unfortunately, while Time Machine can back up to a network volume, by default it only supports a specially presented volume served via Apple&#8217;s network filling protocol (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Apple_Filing_Protocol\">AFP<\/a>) from Leopard Server. You can back up to other choices (e.g., Windows or Linux) via Microsoft&#8217;s filing protocol (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Cifs\" target=\"_blank\">CIFS<\/a>). To do this, you first need to have a native Apple file system to copy the data to.<\/p>\n<p><strong>Creating a sparseimage<\/strong><\/p>\n<p>OS X has supported disk images since the beginning but has recently added a format called sparseimage that starts small but grows as more data is added to it. To use a network volume, you first need to create the image that your machine will be storing the actual data in. Type the following on a mac creating the disk on a local hard drive first:<\/p>\n<p style=\"padding-left: 30px;\"><code>hdiutil create -library SPUD -size <span style=\"color: #339966;\">$SIZESPEC<\/span> -fs HFS+J -type SPARSEBUNDLE \\<br \/>\n-tgtimagekey sparse-band-size=262144 -volname \"Backup of <span style=\"color: #008000;\">$MACHINENAME<\/span>\" \\<br \/>\n$MACHINENAME_<span style=\"color: #339966;\">$MAC<\/span>.sparsebundle<\/code><\/p>\n<p>Here are\u00a0explanations\u00a0on the options that you&#8217;ll want to change:<\/p>\n<p style=\"padding-left: 30px;\">$SIZESPEC \u2013 the size of the virtual disk when filled. A good choice is twice the size of what you&#8217;re backing up.<\/p>\n<p style=\"padding-left: 30px;\">$MACHINENAME &#8211; The name of your machine<\/p>\n<p style=\"padding-left: 30px;\">$MAC &#8211; The network address of the primary network interface without separators (e.g., aabbccddeeff0011). You can get this from System Profiler or Network Utility.<\/p>\n<p>For education purposes, here is some explanation of some of the other items:<\/p>\n<p style=\"padding-left: 30px;\">-fs HFS+J \u2013 make the filesystem HFS+ with Journaling (the default OS X filesystem)<\/p>\n<p style=\"padding-left: 30px;\">sparse-band-size \u2013 the size of the &#8216;chunks&#8217; that make up the sparseimage (they aren&#8217;t just one single file). Normally, the images are made in 8M chunks but those perform quite poorly over the network. The value provided above represents 128M chunks (2 * 128 * 1024 512-Byte-Blocks = 262144 = 128MB) which is a good size for a hard disk backup.<\/p>\n<p>Copying the image to to the network volume is as simple as dragging the sparseimage file via the Finder or do it in the terminal:<\/p>\n<p style=\"padding-left: 30px;\"><code>cp -r $MACHINENAME_$MAC.sparsebundle \/Volumes\/path\/to\/destination<br \/>\n<\/code><\/p>\n<p>The last part is to tell the system to allow any network volume as a destination and not just AFP:<\/p>\n<p style=\"padding-left: 30px;\"><code>defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1<\/code><\/p>\n<p><strong>Using just part of a drive<\/strong><\/p>\n<p>For some reasons you&#8217;ll see below, I wanted to limit the usage of the destination drive local to the system. Normally, Time Machine will use all the space of an external drive chosen as the destination. If you are storing other information on it, that can become a problem. The solution is to convert the physical Time Machine destination volume into a disk image.<\/p>\n<p>The first step is to create a disk image with the same information above. Next, mount the newly created disk image:<\/p>\n<p style=\"padding-left: 30px;\"><code>hdiutil mount \/path\/to\/created\/imagefile<\/code><\/p>\n<p>You can also mount it simply by double-clicking on the disk image file. You&#8217;ll then copy the contents of the current Time Machine volume to the created disk image. Note, it is best to ensure Time Machine is disabled as you don&#8217;t want anything changing as you are copying it:<\/p>\n<p style=\"padding-left: 30px;\"><code>sudo asr restore --source \/Volumes\/srcvol --target \/Volumes\/Backup\\ of\\ $MACHINENAME<\/code><\/p>\n<p>asr is Apple&#8217;s System Restore utility and it performs copy between volumes but ensures that everything is copied properly. You need the sudo portion to have the command be able to access every file which may not be the case if run just as yourself.<\/p>\n<p>Of course, this copy can take some time depending on the speed of your system but mostly due to the size of the data being copied.<\/p>\n<p>Once completed, you can unmount the disk image and configure Time Machine to use the disk that the disk image is stored on. Time Machine is smart enough to use the image if it sees it (the file has to be at the top-level of the destination hard drive).<\/p>\n<p><strong>Trigger a Time Machine backup from the command-line<br \/>\n<\/strong><\/p>\n<p>If you ever want to trigger a Time Machine backup on a system from the command-line, perhaps on a remote system via ssh, issue the following command:<\/p>\n<p style=\"padding-left: 30px;\"><code>\/System\/Library\/CoreServices\/<a class=\"linkification-ext\" title=\"Linkification: http:\/\/backupd.bundle\/Contents\/Resources\/backupd-helper\" href=\"http:\/\/backupd.bundle\/Contents\/Resources\/backupd-helper\">backupd.bundle\/Contents\/Resources\/backupd-helper<\/a> -auto<\/code><\/p>\n<p><strong>Exclude an individual file from being backed up<br \/>\n<\/strong><\/p>\n<p>You can exclude files from being backed up (like previously mentioned virtual disks) using the GUI in the Time Machine preferences (under Options), but it can also be done using the extended attributes in the command-line:<\/p>\n<p style=\"padding-left: 30px;\"><code>xattr -w com.apple.metadata com_apple_backup_excludeItem \/path\/to\/file\/to\/exclude<\/code><\/p>\n<p>Similarly, you can see if a file is being excluded but listing the extended attributes:<\/p>\n<p style=\"padding-left: 30px;\"><code>xattr -l \/path\/to\/file\/in\/question<\/code><\/p>\n<p><strong>Hide the Time Machine disk in the Finder<br \/>\n<\/strong><\/p>\n<p>If you aren&#8217;t getting all fancy and writting to a disk image, you may want to hide the destiation disk. You can do that just by making the volume invisible:<\/p>\n<p style=\"padding-left: 30px;\"><code>SetFile -a V \/path\/to\/Time\/Machine\/Volume<br \/>\n<\/code><\/p>\n<p><strong>Conclusion<br \/>\n<\/strong><\/p>\n<p>I hope this has been helpful to you and that with the information are able to make a useful tool even more useful. To give credit where credit is due, I&#8217;ve included below the links to where much of the information was originally found.<\/p>\n<p><strong>Update<\/strong><\/p>\n<p>20090527 I&#8217;ve revised the sparse-band-size value from 1G to 128M which is the largest band currently support in 10.5.7. Files with larger band files cannot be mounted in 10.5.7. Once I determine the correct procedure for converting an old image, I&#8217;ll post a new article. In the meantime, you can get more information <a href=\"http:\/\/discussions.apple.com\/thread.jspa?messageID=9502958\" target=\"_blank\">here<\/a>.<\/p>\n<p><strong>Reference<\/strong><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/www.macosxhints.com\/article.php?story=20080420211034137\" target=\"_blank\">10.5:\u00a0Set up Time Machine on a NAS in three easy steps<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/www.macosxhints.com\/article.php?story=2008050913104691\" target=\"_blank\">10.5: Improve networked Time Machine performance<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/developer.apple.com\/documentation\/Darwin\/Reference\/ManPages\/man1\/hdiutil.1.html\" target=\"_blank\">Man page for hdiutil<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/developer.apple.com\/documentation\/Darwin\/Reference\/ManPages\/man8\/asr.8.html\" target=\"_blank\">Man page for asr<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/www.entropy.ch\/blog\/Mac+OS+X\/2008\/06\/14\/Exclude-Items-From-Time-Machine-Backup-With-Contextual-Menu.html\" target=\"_blank\">Exclude Items From Time Machine Backup With Contextual Menu<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/db.tidbits.com\/article\/9607\" target=\"_blank\">Time Machine Exposed!<\/a><\/p>\n<p style=\"padding-left: 30px;\"><a href=\"http:\/\/www.macworld.com\/article\/132782\/2008\/04\/finderhidetm.html\" target=\"_blank\">Hide Time Machine&#8217;s icon in the Finder<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been learning a lot about the Time Machine feature of Apple&#8217;s OS X 10.5 (Leopard) and wanted to take the time to share my experience. In a nutshell, Time Machine watches the files that get modified on your system &hellip; <a href=\"https:\/\/mike.peay.us\/blog\/archives\/248\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12,3],"tags":[],"class_list":["post-248","post","type-post","status-publish","format-standard","hentry","category-apple","category-geek"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4vft-40","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/posts\/248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/comments?post=248"}],"version-history":[{"count":6,"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/posts\/248\/revisions"}],"predecessor-version":[{"id":316,"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/posts\/248\/revisions\/316"}],"wp:attachment":[{"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/media?parent=248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/categories?post=248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mike.peay.us\/blog\/wp-json\/wp\/v2\/tags?post=248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}