View previous topic :: View next topic |
Author |
Message |
Dralnu Veteran
Joined: 24 May 2006 Posts: 1919
|
Posted: Sun Feb 11, 2007 5:16 am Post subject: Backing up a hardrive for a new install |
|
|
Ok. I've got a 300G Seagate I'm wanting to backup to a partiton on my 80GB WD (it will fit, I know), and I'm wondering what the best way to do this would be? I'm wanting to repartition my hda (seagate), and need to backup everything.
I've looked over trying to do it with tar -cjf, but thats slow, cumbersome, and I don't trust it for some reason. dd seems promising, but I'd like feedback from someone who knows this kind of thing better than I. _________________ The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner. |
|
Back to top |
|
|
timeBandit Bodhisattva
Joined: 31 Dec 2004 Posts: 2719 Location: here, there or in transit
|
Posted: Sun Feb 11, 2007 5:36 am Post subject: |
|
|
I've found this absolutely bulletproof: Code: | cd /source
find . -depth -print0 | cpio -0dmvp /target |
The same pipleines work to restore, simply reverse source and target. This preserves all permissions, ownership and timestamps (not sure about ACLs, but it should).
If you need to compress the source to make it fit, run cpio in copy-out mode instead of passthrough (-o instead of -p) and pipe it through gzip: Code: | find . -depth -print0 | cpio -0vo | gzip >/target/backup.cpio.gz | In this case, use copy-in mode (-i) to restore: Code: | cd /restore-point
gunzip -c /target/backup.cpio.gz | cpio -dmvi |
I've rearranged and resized partitions on several occasions using cpio, without a hitch. Like you I never found tar (nor zip) satisfactory for this. If you trust long silences, leave off the -v option and it will run a bit faster but without feedback (no filenames printed). _________________ Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others. |
|
Back to top |
|
|
Dralnu Veteran
Joined: 24 May 2006 Posts: 1919
|
Posted: Sun Feb 11, 2007 6:11 am Post subject: |
|
|
timeBandit wrote: | I've found this absolutely bulletproof: Code: | cd /source
find . -depth -print0 | cpio -0dmvp /target |
The same pipleines work to restore, simply reverse source and target. This preserves all permissions, ownership and timestamps (not sure about ACLs, but it should).
If you need to compress the source to make it fit, run cpio in copy-out mode instead of passthrough (-o instead of -p) and pipe it through gzip: Code: | find . -depth -print0 | cpio -0vo | gzip >/target/backup.cpio.gz | In this case, use copy-in mode (-i) to restore: Code: | cd /restore-point
gunzip -c /target/backup.cpio.gz | cpio -dmvi |
I've rearranged and resized partitions on several occasions using cpio, without a hitch. Like you I never found tar (nor zip) satisfactory for this. If you trust long silences, leave off the -v option and it will run a bit faster but without feedback (no filenames printed). |
I'll look into this. Thanks for the reply.
Edit:
Looking over your script, the /source is the top dir I would want to save, correct? And the /target is the directory/drive I'm copying to, right? _________________ The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner. |
|
Back to top |
|
|
timeBandit Bodhisattva
Joined: 31 Dec 2004 Posts: 2719 Location: here, there or in transit
|
Posted: Sun Feb 11, 2007 6:28 am Post subject: |
|
|
Yes ... I was too tired and lazy to come up with anything more explicit, and from what I've read by you I figured you'd get my drift.
I should clarify though, that I assumed you will mount both filesystems. You could pipe the archive straight onto a raw disk device, but then it wouldn't have a filesystem anymore and only cpio could read it back. If it's only a temporary holding tank while you rearrange other partitions, that would actually be a lot faster. I've never tried it that way--it should be just as reliable, but you lose the warm fuzzy feeling of having an accessible (mountable) copy at all times. _________________ Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others. |
|
Back to top |
|
|
Dralnu Veteran
Joined: 24 May 2006 Posts: 1919
|
Posted: Sun Feb 11, 2007 7:30 am Post subject: |
|
|
timeBandit wrote: | Yes ... I was too tired and lazy to come up with anything more explicit, and from what I've read by you I figured you'd get my drift.
I should clarify though, that I assumed you will mount both filesystems. You could pipe the archive straight onto a raw disk device, but then it wouldn't have a filesystem anymore and only cpio could read it back. If it's only a temporary holding tank while you rearrange other partitions, that would actually be a lot faster. I've never tried it that way--it should be just as reliable, but you lose the warm fuzzy feeling of having an accessible (mountable) copy at all times. |
Its a mouned drive. Not always, but it will be for this. I'll probably start it before I go to bed, since I got a feeling it will take quite a long while... _________________ The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner. |
|
Back to top |
|
|
leonglass Apprentice
Joined: 08 Aug 2006 Posts: 278
|
Posted: Sun Feb 11, 2007 12:14 pm Post subject: |
|
|
Thanks guys this answers a question I had about copying an external disk that I carry between home and work. I wish to back it up on my desktop machine and use it as a working copy of the files. cpio looks to be what I need in copy-pass mode.
[Edit] I ran the command and it does not seem to copy all of the directories on the hard drive and I can't figure out why. I used the command
Code: |
find . -depth -print0 | cpio -0dmvp ~/usb-backup
|
I investigated the arguments and it looks like they are the ones I need. the d creates directories the 0s create nulls instead of newlines. Any ideas where it is going wrong. Is there some limit to the size of the drive this can manage. I am trying to copy 4.9gb.
[Edit] Seems to be having a problem with a dir called Recycled which I am assuming is created on the Windows machine at work. I don't seem to be able to delete it either rm -R on it gives the message
Code: |
rm: FATAL: directory `Recycled` changed dev/ino
|
It totals 1.4 mb my process from above seems to bomb during the copying of this dir. Obviously I have no need to copy deleted stuff any ideas how to get around this. |
|
Back to top |
|
|
timeBandit Bodhisattva
Joined: 31 Dec 2004 Posts: 2719 Location: here, there or in transit
|
Posted: Sun Feb 11, 2007 4:13 pm Post subject: |
|
|
leonglass wrote: | Is there some limit to the size of the drive this can manage. I am trying to copy 4.9gb. | No limit. I've copied partitions twice that size.
Three things I can think to try:
1. Make sure no other process writes to the disk during the copy. Mounting the external drive read-only is the best way to be certain.
2. Run a disk-check on the drive's filesystem, from Windows (assuming you didn't reformat the drive from Linux). That should untangle any damage to metadata for the Recycled directory.
3. rm -rf Recycled (note -r not -R), in case it's actually a file inside the dir that's causing trouble. Windows will recreate the directory when needed. (Obviously not while disk is mounted RO ). _________________ Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others. |
|
Back to top |
|
|
leonglass Apprentice
Joined: 08 Aug 2006 Posts: 278
|
Posted: Sun Feb 11, 2007 4:50 pm Post subject: |
|
|
Quote: | No limit. I've copied partitions twice that size. |
Didn't think it would be that really. I tried your command rm -rf and get messages about circular dependancies. I will disk check it at work and that should sort it out. Ironic really as if it is ever plugged in at work when I boot I generally don't let Windows disk check it.
Thanks a lot for the help. |
|
Back to top |
|
|
timeBandit Bodhisattva
Joined: 31 Dec 2004 Posts: 2719 Location: here, there or in transit
|
Posted: Sun Feb 11, 2007 5:11 pm Post subject: |
|
|
I had another thought (impressive in itself, right before lunch ): you can exclude the problem directory from the copy.
Code: | find . -depth ! -wholename 'Recycled*' -print0 | cpio -0dmvp ~/usb-backup |
Once you've done that--which should work if the filesystem corruption is limited to the Recycled directory--you can try repairing the filesystem from Linux if you like. I stressed trying on the Windows machine first to protect your other data, in case you had an NTFS drive or the damage somehow confused fsck. _________________ Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others. |
|
Back to top |
|
|
leonglass Apprentice
Joined: 08 Aug 2006 Posts: 278
|
Posted: Sun Feb 11, 2007 5:59 pm Post subject: |
|
|
Tried that and there seems to be other dirs with a problem. I am currently copying dirs that are important (quite a bit of cruft that I don't really need) and then I will use fsck on it. Once again thanks for the help much appreciated. |
|
Back to top |
|
|
Dralnu Veteran
Joined: 24 May 2006 Posts: 1919
|
Posted: Sun Feb 11, 2007 7:36 pm Post subject: |
|
|
leonglass wrote: | Tried that and there seems to be other dirs with a problem. I am currently copying dirs that are important (quite a bit of cruft that I don't really need) and then I will use fsck on it. Once again thanks for the help much appreciated. |
I'd suggest scripting it all out, and use a set of variables to set the dirs you want to save. _________________ The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner. |
|
Back to top |
|
|
Dralnu Veteran
Joined: 24 May 2006 Posts: 1919
|
Posted: Sun Feb 11, 2007 7:38 pm Post subject: |
|
|
timeBandit wrote: | Code: | cd /source
find . -depth -print0 | cpio -0dmvp /target |
Code: | find . -depth -print0 | cpio -0vo | gzip >/target/backup.cpio.gz | In this case, use copy-in mode (-i) to restore: Code: | cd /restore-point
gunzip -c /target/backup.cpio.gz | cpio -dmvi |
|
Rethinking this, did you mount the drives ro to save from having a problem with things changing due to I/O, or kept them rw? _________________ The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner. |
|
Back to top |
|
|
timeBandit Bodhisattva
Joined: 31 Dec 2004 Posts: 2719 Location: here, there or in transit
|
Posted: Sun Feb 11, 2007 9:17 pm Post subject: |
|
|
Depends. When I moved my portage tree to a new partition earlier this week, I just mounted it RO (I always have /usr mounted RO anyway). For wholesale disk redecorating, I either boot from a LiveCD or drop to single-user mode, as needed. _________________ Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others. |
|
Back to top |
|
|
Dralnu Veteran
Joined: 24 May 2006 Posts: 1919
|
Posted: Sun Feb 11, 2007 10:06 pm Post subject: |
|
|
timeBandit wrote: | Depends. When I moved my portage tree to a new partition earlier this week, I just mounted it RO (I always have /usr mounted RO anyway). For wholesale disk redecorating, I either boot from a LiveCD or drop to single-user mode, as needed. |
Good to know. I'm building a LiveCD, so I may throw this into that and make it a nice utility. May script it out some to make it a bit handier to use, but I'll probably throw it in there. _________________ The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner. |
|
Back to top |
|
|
|