LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Can I "Back up" my system by copy and paste? (ext4) (http://www.linuxquestions.org/questions/linux-general-1/can-i-back-up-my-system-by-copy-and-paste-ext4-946980/)

pgibsonorg 05-26-2012 09:24 AM

Can I "Back up" my system by copy and paste? (ext4)
 
I've got my linux laptop (CentOS 6) with many source-built applications, lots of modified configuration, and a few spare keywords in the grub config.
I'm hoping to (restore-ably) back up the entire system by simply copying all the files on the root partition, and the relevant ones in the /boot partition.
Is this do-able? is it straightforward?
Am I crazy? lol.

I know there are other backup options but I figured this may be easier to restore from.

Teufel 05-26-2012 09:33 AM

you can save image of entire partition including mbr. It's a most easy way. Acronis or dd can help you. Copy/paste doesn't restore main boot record.

pgibsonorg 05-26-2012 09:37 AM

Quote:

Originally Posted by Teufel (Post 4688142)
you can save image of entire partition including mbr. It's a most easy way. Acronis or dd can help you. Copy/paste doesn't restore main boot record.

Yes of course, but would this only be required for the boot partition? or both? If simply copy/paste works for the root partition it would reduce the space needed (dd a drive of mostly empty space seems a bit overkill)

Having a separate boot partition has it's advantages, is this one of them?

Teufel 05-26-2012 05:40 PM

If you have two partitions (/boot and /) you can save root (/) as simple gzip archive. But I am not sure this way is correct for /boot. As well you can't save mbr in this manner.
Also you can combine dd with gzip in order to reduce image size (if you confused with empty space).
Something like this:
Code:

# dd if=/dev/sda conv=sync,noerror bs=64K | gzip -c > /mnt/sdb1/sda.img.gz
here /dev/sda is disk you want to backup, /mnt/sdb1 - destination partition for saving backup archive (usb stick/hard e.t.c.)

and how to restore it from archive:
Code:

# gunzip -c /mnt/sdb1/sda.img.gz | dd of=/dev/sda conv=sync,noerror bs=64K

syg00 05-26-2012 10:00 PM

Allow me to toss in dissenting view.
"dd" is absolutely unequivocally the worst option for backup. Especially with "noerror".

Use a filesystem aware tool like rsync or cp so you know if/when the source has errors. Better to find out right there, right then. Likewise, copying MBR is very dodgy - any change to partitions after the backup is just a disaster waiting to happen. Just reinstall the boot-loader (to the MBR, not a complete package re-install) after any restore.

Teufel 05-27-2012 04:24 AM

Yes, if you need just a files copy you can use cp, but cp doesn't give you image.
"conv=sync,noerror" option preserves real image size if some blocks are unreadable.
Also if you going to change your partitions (size, order, GUID e.t.c.), the best way to restore is just fresh installation from distribution media.

unSpawn 05-27-2012 06:32 AM

I agree with the rsync option because with Centos, and basically any RPM-based installation, you wouldn't need backups of /bin, /sbin, /usr and those other areas that hold libraries, binaries, etc, etc the system only modifies on installation and update. RPMDB output should be enough to rebuild a system, leaving only contents that have changed like /boot/grub*, /selinux, /etc, /var (need some exclusions there as you don't need cache/yum for example), /root and /home. And if you rsync inside a script you can easily save the MBR to file and have it backed up as well.


All times are GMT -5. The time now is 04:01 PM.