Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 06-09-2004, 07:00 AM   #1
LQ Newbie
Registered: Jan 2004
Posts: 18

Rep: Reputation: 0
Full Backup With Cpio!


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
Old 06-09-2004, 09:29 AM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
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.

Last edited by homey; 06-09-2004 at 09:45 AM.
Old 06-10-2004, 12:47 AM   #3
LQ Newbie
Registered: Jan 2004
Posts: 18

Original Poster
Rep: Reputation: 0
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.

Old 06-10-2004, 07:51 AM   #4
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
Here's another option.
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.....
Old 09-16-2010, 01:11 AM   #5
LQ Newbie
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
To Exclude Directories

Use: grep -v


# find . -depth -print | grep -v proc| grep -v tmp| grep -v dev| cpio -ov > /babckup/full_backup.cpio
Old 06-14-2011, 03:12 PM   #6
Senior Member
Registered: Feb 2003
Location: Washington D.C
Posts: 2,171

Rep: Reputation: 60
I though I just add a belated solution, try this:

find . \( -wholename ./proc -o -wholename ./dev -o -wholename ./tmp \) -prune -o -print | cpio -oav > /babckup/full_backup.cpio
just simple replace my directories with your. Cheers

Last edited by metallica1973; 06-14-2011 at 03:14 PM.
1 members found this post helpful.
Old 02-09-2012, 06:43 AM   #7
LQ Newbie
Registered: Mar 2009
Posts: 3

Rep: Reputation: 0
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. -


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Full system backup. Terroth Linux - Newbie 11 06-21-2005 12:52 AM
using cpio to create hard drive backup file bobsmith Linux - Newbie 2 10-20-2004 10:30 AM
Using cpio to backup to CDROM Cyberhund Linux - Newbie 3 07-21-2004 01:49 PM
Full Backup.... LinuxBie Linux - Newbie 3 01-02-2004 10:43 AM
full system backup dbc254 Linux - General 6 12-26-2003 09:27 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration