backing up a mounted filesystem?

General support questions including new installations
Post Reply
rcrayons
Posts: 1
Joined: 2007/01/21 17:56:50

backing up a mounted filesystem?

Post by rcrayons » 2007/01/21 19:33:56

Hello,

I would like to make a clean backup of my current CentOS 4.4 installation before I muck around with it more. I will try to stay somewhat focused with my question(s). Comments to any piece of this would be helpful.

I have an installation with separate partitions/filesystems for (/,/boot,/home,/opt,/usr,/var). I have used roughly the following command to back up each partition individually. Appears to work great, I am happy enough with the compression and I'm not concerned about the speed because I am going from one disk to another disk on the same machine.

dd if=/dev/hda7 | gzip -9 >/data1/linuxbu/hda7image.dd.gz

The questions I have around this are as follows, with my primary concern is 1&2.
1) dd does not seem to care if the filesystem is mounted when I take a snapshot of it. This "seems" wrong, but I don't really know, and am not aware of a way to unmount certain filesystems, particularly /,/usr,/var. Even if I bring the runlevel down to 1, I still have various processes running that use especially the / & /usr directories. So my question is really wondering if my backup snapshots using dd with mounted filesystems are a clean way to take a backup of a partition?

2) I suppose the other side of the same coin is - even if I get a perfect snapshot of these disk partitions, I imagine I would have to restore them to /dev/hdaX when those filesystems are not mounted? How could I not have / or /usr mounted for example when perform the restore? The only idea I have is to make a flash drive I can boot to with the needed pieces (kernel, dd, gzip, mount, etc...), and run my partition backup from there. Would that be a better approach than trying to deal with mounted filesystems?

3) There are other archiving commands out there. What are the reasons that a person would use tar/dump/pax instead of dd (keeping the same context of an entire partition as the target)?

Thanks,
Eric

pjwelsh
Posts: 2622
Joined: 2007/01/07 02:18:02
Location: Central IL USA

Re: backing up a mounted filesystem?

Post by pjwelsh » 2007/01/21 20:15:20

"rsync" *may* be a better option. rsync operates at a mounted filesystem level and is good for help figure out *what* has changed (dd won't do that). There are other dd and rsync like options "g4l" (ghost for linux), "g4u" (ghost for unix), rdiff-backup (librsync + differential backups) etc. (avoid the /proc FS, it's not realy a FS).

dd is not usually a good idea on a mounted FS, but it realy just depends. You may may to make sure to run "sync" to sync the OS buffers to disk before doing anything. The g4? options are seperate bootable utilites that create images of you disk(s), so they are not mounted in that case.

chattr
Posts: 76
Joined: 2006/01/27 09:54:28

backing up a mounted filesystem?

Post by chattr » 2007/01/22 10:15:15

If you are using the Logical Volume manager, you can create 'snapshot' volumes to create backups.

Quote:
"A snapshot volume is a special type of volume that presents all the data that was in the volume at the time the snapshot was created. This means we can back up that volume without having to worry about data being changed while the backup is going on".


See the LVM howto for further details.


If you are not using LVM (and I suspect you aren't as you mention /dev/hda*), rsync or tar are good options for backup.

Post Reply

Return to “CentOS 4 - General Support”