Full Backup With Cpio!
Hello!
I want to make a full backup of my hard drive using CPIO command under Suse (SLES 8). I have these partitions on my hard drive: - /dev/sda1: /boot 100MB (reiserfs) - /dev/sda2: /root 4GB (reiserfs) - /dev/sda1: /swap 2GB - /dev/sda1: /opt rest of hard drive (reiserfs) I used CPIO command to make full backup of my hard drive: # cd / # find . -depth -print | cpio -ov > /babckup/full_backup.cpio But I need to exclude some directories (proc, tmp, dev) when I make backup. How can I do this? In case I lose hard drive I plan to get new hard drive, install basic OS, copy backup file to new hard drive (to /) and restore it with cpio. Will this work? Because I have some doubts about restoring and replacing files while they are been used by OS (etc for example). How about a TAR? Should I use that? Thank in advance |
I like cpio but off-hand I haven't seen any instructions for excluding directories using that tool. It can save the output as tar and several other types though. Something like this....
find . -depth | cpio --create --format=tar > /mnt/backups/test.tar If you use the tar utility instead, you could tell it what to backup by reading a list. You can make the list by hand or use ls to make it. Then you can edit the list to remove dirtectories which you don't want backed up. ls -d *"/" > /home/list.txt The tar statement would look like this...... tar -cvf /mnt/backups/test.tar \ -T, --files-from=/home/list.txt Really though, I'm a fan of the partimage tool for making my system images. :) |
I've tried partimage.
Works OK. But when you make backup with partimage you need to unmount partition that you are backing up. I need to have all partitions available all the time. I'll try tar, but I think that tar restore only files that don't allready exist on hard drive. So, I don't know will tar restore old config files. Thanks! |
Here's another option. http://www.mondorescue.org/docs/docs.html
Somehow, it can work on a live system and you can put the backup onto a bunch of different things like an iso image or cdrom..... |
To Exclude Directories
Use: grep -v
Example: # find . -depth -print | grep -v proc| grep -v tmp| grep -v dev| cpio -ov > /babckup/full_backup.cpio |
I though I just add a belated solution, try this:
Code:
find . \( -wholename ./proc -o -wholename ./dev -o -wholename ./tmp \) -prune -o -print | cpio -oav > /babckup/full_backup.cpio |
Hello thank's metallica1973
I used your instruction now to backup my full system but system only not /home directory's or other drives. I do not create a .cpio file but use pass trough copy. hardrive space is not a problem, I use a seperated internal drive for my backup's. Which is mounted on /media/databackup (made an fstab entry for it) The modified instruction here. find . \( -wholename ./proc -o -wholename ./dev -o -wholename ./tmp -o -wholename ./var/run -o -wholename ./sys -o -wholename ./media -o -wholename ./home \) -prune -o -print | cpio -apdmv /media/databackup/linuxos cpio options -p passtrough copy in out -d make dirs -m preserve modification -v verbose -a reset-access-time *note i also ignored de /var/run For the home directory I just backup as root using cp cp -afprv /home/myhomedir /media/databackup/home cp options -a = archive -f= force -p = preserve -r= recursive -v= verbose to show actions performed To make my life easy I just make scripts of it which I run as sudo. -:) |
All times are GMT -5. The time now is 07:06 PM. |