![]() |
back up/ file compression
Is there a way I can compress my home directory information in the terminal? I want to back up my home folders and preferences on CD-rw. I had read something recently about tar. compression or something like that. I would be very grateful for a tutorial link or info.
Thanks, Destin |
Hello, take a look at "hfspax". You can find it here: http://homepage.mac.com/howardoakley/
It contains a very good tutorial and many infos about unix compression & archive tools. |
Depending on how much data you have in your home folder you might get away with tar:ing it directly on the CD-R. From your home directory:
$ tar cvzf /Volumes/NameOfYourCD-R-Disc/MyHomeFolder.tgz . tar takes several flags and arguments. The flags above are c for create archive, v for be verbose and print the names of the files you are archiving, z for gzip-compress the archive, f for file archive (as opposed to spitting out the archive on standard out I think). The last argument here is . (dot) for the current directory. But you can give a list of specific directories as well. |
Thanks
Thank you both!
Destin |
osxpez......
Osxpez,
Well, I just attempted to tar my home directory to a cdr, but the pipe failed because there was not enough space on the disk. Is their a way that i can tar the individual folders in my home directory? Would this work?: % tar cvzf /Volumes/NameOfCD-R_Disc/Documents.tgz . Doing a tar for each folder? Pictures, movies etc.... I believe my psd. docs take up alot of space. Thanks Destin |
Re: osxpez......
Quote:
For the sake of completeness, you really want to use the following: Code:
% tar cvzf /Volumes/NameOfCD-R_Disc/home.tgz /Users/<your username>/My own backup solution involves backing up my home directory every morning to a disk image, and then compressing THAT. At the end of each week, I burn the latest image on to a multi-session CD. I think that's a little safer, as I'm not sure how nicely tar treats resource forks. I've had a few headaches from backing up files to linux servers, then restoring files that Mac OS can't recognise. Nasty. Disk Images may even compress better, but I'm not sure... |
thanks
Thanks jaybee. Now that I reread osxpez's post, this seems obvious. Thanks for taking the time and patience to post. I appreciate the help.
Thanks, Destin |
justa follow up
Every thing worked perfectly, my user folder is completely backed up. Thanks for all the help.
Cheers, Destin |
er, uh, doesn't tar miss the resource forks?!
|
er, uh, doesn't tar miss the resource forks?!
er, uh, doesn't tar miss the resource forks?!
Merv....... Do I need to be concerned about resource forks when I am backing up the contents of my Pictures, Video, and Documents folders? I am sorry if this sounds stupid. Destin |
Re: er, uh, doesn't tar miss the resource forks?!
Quote:
the point is, you have to know. are there rez forks that i am missing? does my backup have any integrity? if tar misses the rez forks, then i can't rely on it to backup my $HOME at all, because i don't want to have to know whether a file has a rez fork or not. i just want the backup to have integrity. e.g., Code:
$ pwdit boils down to situational awareness and reasonable assurity. if you're aware that files in your backup set don't have rez forks and you're assured that new files or changes won't create them, then tar backup should have integrity. |
Quote:
Anyway, as I pointed out, I'm not sure if tar munges resource forks. It may not be important for data files such as your images etc - these are platform independent mainly, and you can just re-associate them by dragging on to app icons etc. However, if you want a universal backup solution, you really have to take resource forks into account. As I say, the safest way to do ANY CD based backup (or more generally, any backup which involves a non-HFS+ filesystem), you really want to use disk images. A disk image will preserve EVERYTHING about your directories by creating an exact sector-for-sector replica. You can then burn the image AS A FILE on to the CD (or upload it onto a server, or whatever) safe in the knowledge that all the underlying structure of the filesystem you've backed up is being preserved. if you "man hdiutil" and have a scan through there, you'll find out how to create images in the terminal. This is easily scripted up, and can be used to automate your backups for those times you feel ultra-paranoid :) In fact, right at the end of the man page, there's a worked example of how to backup a complete folder to a disk image: Code:
Image from folder:The "du" line measures the total size of your backup candidate. You then use hdiutil to create an image slightly larger than this, to make room for file-system stuff. The rest of the code just takes this image, attaches it as a device, formats it, mounts it in finder, then uses ditto to copy the files across ("ditto -rsrc <source> <target>" or "ditto -rsrcFork <source> <target>" are identical commands to copy files while preserving resource forks). You can then eject the image in finder, and you end up with a file (called "folderImage.dmg" in this case) that you can compress into a tarball to your heart's content. This is a much safer way to do things IMHO, although I've never compared the compression ratios of diskImage.tar vs plainFiles.tar. Frankly however, unless you're REALLY pushing it to compress under 650MB, I don't think you'll be wasting many CDs by using the disk image method - CDs are cheap, and resource forks are expensive ;) Hope this helps! |
Re: er, uh, doesn't tar miss the resource forks?!
Quote:
|
Thanks guys, I have alot to learn ...............
jaybee ...... If I follow the prompts you outlined, I will effectively create a disk image( on the desktop or in the finder) which has a copy of my home folder: ditto -rsrcFork myFolder /Volumes/myFolderImage is the 'myFolder' my home folder name, or is it just part of the script? I am guessing that /Volumes/"my home folder name" is correct. Sorry if I am unclear. If I make my home folder a disk image, I maintain the resource forks? If I tar the disk image, does the resource forks remain intact? Thanks, destin |
never mind, figured it out...... sorry
|
Quote:
so, your home is /Users/username and can be short-handed by ~ or $HOME in scripts. re: disk image, that's a really interesting thing you said. since you ditto -rsrc to the image, rez forks are captured, and since they are 'wrapped' in another 'container', tar will get the goods; tar will be backing up one file, the image that contains what it contains. you see? slick. but a little onerous, stepwise. |
<edit>
Speed was never my strong point, guys! Ach, I'll leave this up anyway, for the sake of completeness... </edit> Quote:
Anyway, on to your specific. After pointing out that using a "." location was unclear, I went and did the same thing! Let's go through this :) Let's say your home folder lives at /Users/pyrogen/, and that you want to back it all up (including your Library, which is where all your settings and your mail is stored). If you want to back up something else, just replace this path with another. Let's also say that we want to put the resultant image into the Shared folder (/Users/Shared). Putting it on the Desktop is a Bad Idea, as we are going to be backing up the desktop, and it's going to be really tricky to try to copy a file into itself... Code:
% du -s /Users/pyrogenAnyway, this returns a number. In my case I got 227780. This is the number we use to work out the size of disk image we need to create in order to back up the folder. Code:
% hdiutil create -sectors 244864 /Users/Shared/pyrogen_backupI got 7.5% by trial and error - I'm sure there's a more precise way to work this stuff out, but basically if you are told that you've run out of disk space later on, try altering the factor here and see if that sorts it. Anyway, this line creates a file at /Users/Shared/pyrogen_backup.dmg. This is our disk image file. However, right now, it's just a file of a certain size. Code:
% hdid -nomount /Users/Shared/pyrogen_backup.dmgIn particular, if you've scripted this process up, you don't want the script to hang while it waits for user input. The output from this command will be along the lines of: Code:
/dev/diskX Apple_partition_scheme First, however, we have to format the disk. To do this, you need to find out what disk number we're dealing with - ie what the X value is for your system. In my case it was 3, but you'll probably find it's 2 (if you have no CDs/disk images already mounted, and you only have one hard disk). Code:
% newfs_hfs -v pyrogensBackup /dev/diskXs2The pyrogensBackup bit is the NAME of your disk. This is the label you'll see when you mount the disk in Finder. Code:
% hdiutil eject diskXCode:
% hdid /Users/Shared/pyrogen_backup.dmgCode:
/dev/diskXs2 Apple_HFS /Volumes/pyrogensBackupCode:
% sudo ditto -rsrcFork /Users/pyrogen /Volumes/pyrogensBackupOnce that's done, you can just eject the disk from Finder as you normally would, or, to keep it nice and command-line, use Code:
% hdiutil eject diskXAnyway, hope this rather long winded explanation clears up my mistakes :) |
correction!
Quote:
the target of that newfs is wrong. i think it should be /dev/disk3s2 . JayBee, you might want to edit that. you definitely want to hit the right target here, both with the slice label and its /dev/disk representation. anything else could lead to unexpected results and even disaster. you're script should be oh, so careful here. you might want to use the -N switch in newfs in testing this sucker... /dev/disk3s2 Apple_HFS you absolutely have to get the /dev of the "Apple_HFS" slice. |
Thanks guys!!!!!
Jaybee, thanks for breaking it down for me, thats exactly what I needed. Merv. nice catch! I am off to try this out, I will post back. Thanks agian, Destin |
error
well when I attempt:
% hdiutil create -sectors 2676896 /Users/Shared/pyrogen_backup i get the message: hdiutil: create failed - No such file or directory i believe this is because i have no 'Shared' folder in '/Users' is it acceptable to: % hdiutil create -sectors 2676896 /Users/pyrogen_backup forgoing the 'Shared' folder and creating the disk image in '/Users' ? OR Should I create a shared folder in '/Users'? If so would I use 'mkdir' ? Thanks, Destin |
| All times are GMT -5. The time now is 10:10 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.