Backup Your Data To Insure It Will Be There When You Need It

Backups, like insurance, aren't any fun until an accident happens...

dump

Level 0 dumps entire file system Level 9 dumps everything back to last dump any level Other Levels archive all files modified or added since the last dump of a lower level

How I backup my /home partition

/sbin/dump 0uf - /home | gzip -9 > /usr/local/backups/`/bin/date +%y%m%d`.gz

A sample restore session

61 15:38/tmp> gzip -dc /usr/local/backups/code_961228.gz | /sbin/restore -if -
restore > ls
.:
TT_DB/      code/       ftp/        lost+found/ samba/

restore > cd code/lib/src
restore > ls
./code/lib/src:
Makefile    dname.c     itoa.c      pathmax.h   stringdup.c xmalloc.c
a.out       fatal.c     libutil.h   realp       syserr.c
bname.c     fullpath.c  main.c      realpath.c  xgetcwd.c

restore > add pathmax.h stringdup.c bname.c
restore > ls
./code/lib/src:
 Makefile     dname.c      itoa.c      *pathmax.h   *stringdup.c
xmalloc.c
 a.out        fatal.c      libutil.h    realp        syserr.c
*bname.c      fullpath.c   main.c       realpath.c   xgetcwd.c

restore > extract
set owner/mode for '.'? [yn] n
restore > quit
62 15:39/tmp/code> cd code/lib/src/
63 15:39/tmp/code/lib/src> l
total 4
-rw-r--r--   1 code     code          370 Apr 22  1996 bname.c
-rw-r--r--   1 code     code         1703 Apr 23  1996 pathmax.h
-rw-r--r--   1 code     code          236 Apr 10  1996 stringdup.c

tar

Common Options

-r   :   append files to archive
-c   :   create
-t   :   list (table of contents)
-x   :   extract
-C directory   :   change directory
-f   :   file or device
-l   :   stay on local file system
-O   :   extract to standard out
-p   :   save permissions
-P   :   don't strip '/' from path
-v   :   verbose
-Z   :   filter through compress
-z   :   file through gzip

Examples

tar tf archive.tar   :   List archive contents
tar tzf archive.tar.Z   :   List compressed archive contents
tar xvvf archive.tar   :   Extract files from archive with really verbose output
tar xzpvf archive.tar.gz   :   Extract files from compressed archive and retain permissions
tar xzpvf archive.tar.gz "filename"   :   Extract filename
tar xzpvf archive.tar.gz "directory"   :   Extract directory and files
tar cf /dev/fd0 directory   :   Create archive on device
tar cf archive.tar directory   :   Create archive on file
tar czf archive.tar.gz directory   :   Create compressed archive
tar cf - directory | ( cd /newdir; tar xvpf - )   :   Move a directory
tar cf archive.tar `find /directory -print`   :   Create an archive from a filelist
tar rPf archive.tar "filename"   :   Append a file to an archive

cpio

Common Options

-o   :   create (copy-out)
-i   :   extract (copy-in)
-a   :   reset access time so file doesn't look like it was just read
-A   :   append, archive must be a disk file
-d   :   create leading directories as needed
-F filename   :   archive to filename instead of standard in/out
-m   :   retain previous file modification times
-t   :   list (table of contents)
-v   :   verbose

Examples

find /directory -print | cpio -ov > archive.cpio   :   Copy out directory to archive
find /directory -print | cpio -ovF archive.cpio   :   Copy out directory to file archive.cpio
find /directory -print | cpio -ov > /dev/fd0   :   Copy out directory to device
cpio -ov > /dev/fd0
bigfile
Found end of tape. To continue, type device/file name when ready.
/dev/fd0
bigfile
^D
3902 blocks   :   Interactively archive file to multiple volumes
cpio -idv < archive.cpio   :   Copy in archive
cpio -idv "filename" < archive.cpio   :   Copy in filename from archive
cpio -idv "directory/*" < archive.cpio   :   Copy in glob from archive

An error in compression can cause an entire archive to be unusable...


Last Modified: 15 April 1997

St. Louis Unix Users Group - Linux SIG