Example One - Part 3 - Restoring files
- Archiving files
- Inspecting archives
- Restoring files
Archive files can be accessed in various ways. First there is the obvious normal files access. Since the archive version are organised as regular files
# cd $HOME/zz-backup/wcp # tar czvf 0004 wcp-0004.tar.gz
will produce a normal tarball, only the directory name will look a little bit strange after unpacking. But this will work only if you archive your files on the same host (creating the tar archive requires direct file access).
Listing directories
wcp offers some commands to access archives. The first is
# wcp latest $HOME/zz-backup/wcp 0004 0004
which prints the latest version number and it's name (both "0004" in this case).
The list operation lists server directories, either (without an argument) the archive's top level directory
# wcp list $HOME/zz-backup/wcp drwxr-xr-x 3 1000 1000 4096 Jan 05 15:14 0001 drwxr-xr-x 3 1000 1000 4096 Jan 05 15:15 0002 drwxr-xr-x 3 1000 1000 4096 Jan 05 15:16 0003-test drwxr-xr-x 3 1000 1000 4096 Jan 05 15:27 0004
or a subdirectory.
# wcp list $HOME/zz-backup/wcp 0004 0004: -rw-r--r-- 1 1000 1000 1013 Jan 05 15:27 .wcpd-0004.log -rwxr-xr-x 4 1000 1000 713 Jan 03 22:11 backup-etc -rwxr-xr-x 1 1000 1000 2386 Jan 05 15:24 check-copy -rw-r--r-- 4 1000 1000 5433 Jan 04 01:08 config.c -rw-r--r-- 4 1000 1000 1413 Jan 03 11:57 config.h -rw-r--r-- 4 1000 1000 2593 Jan 03 11:35 io-lib.c -rw-r--r-- 4 1000 1000 1240 Jan 03 11:27 io-lib.h -rw-r--r-- 4 1000 1000 7718 Jan 04 14:08 lib.c -rw-r--r-- 4 1000 1000 1947 Jan 04 14:08 lib.h -rw-r--r-- 2 1000 1000 654 Jan 05 15:15 makefile -rw-r--r-- 4 1000 1000 25725 Jan 05 14:59 server.c -rw-r--r-- 4 1000 1000 2158 Jan 04 01:01 server.h -rw-r--r-- 4 1000 1000 7436 Jan 04 23:49 stat.c -rw-r--r-- 4 1000 1000 1538 Jan 04 23:49 stat.h -rwxr-xr-x 4 1000 1000 133 Jan 04 01:25 test-handler.sh -rw-r--r-- 4 1000 1000 2350 Jan 03 12:17 version.c -rw-r--r-- 4 1000 1000 4530 Jan 05 12:19 wcp.1 -rw-r--r-- 4 1000 1000 25580 Jan 05 14:00 wcp.c -rw-r--r-- 4 1000 1000 1329 Jan 02 19:47 wcp.h -rw-r--r-- 4 1000 1000 4267 Jan 05 15:13 wcpd.1 drwxr-xr-x 2 1000 1000 4096 Jan 05 15:27 zz-test
The list command accepts multiple directory names on it's command line. In this case the directory listings are separated by an empty line.
Restoring files
Restoring files is simple with the restore command, even for remote directories.
# mkdir $HOME/tmp # cd $HOME/tmp # wcp restore $HOME/zz-backup/wcp # ls -l total 148 -rwxr-xr-x 1 wzk wzk 713 2006-01-03 22:11 backup-etc* -rwxr-xr-x 1 wzk wzk 2386 2006-01-05 15:24 check-copy* -rw-r--r-- 1 wzk wzk 5433 2006-01-04 01:08 config.c -rw-r--r-- 1 wzk wzk 1413 2006-01-03 11:57 config.h -rw-r--r-- 1 wzk wzk 2593 2006-01-03 11:35 io-lib.c -rw-r--r-- 1 wzk wzk 1240 2006-01-03 11:27 io-lib.h -rw-r--r-- 1 wzk wzk 7718 2006-01-04 14:08 lib.c -rw-r--r-- 1 wzk wzk 1947 2006-01-04 14:08 lib.h -rw-r--r-- 1 wzk wzk 654 2006-01-05 15:15 makefile -rw-r--r-- 1 wzk wzk 25725 2006-01-05 14:59 server.c -rw-r--r-- 1 wzk wzk 2158 2006-01-04 01:01 server.h -rw-r--r-- 1 wzk wzk 7436 2006-01-04 23:49 stat.c -rw-r--r-- 1 wzk wzk 1538 2006-01-04 23:49 stat.h -rwxr-xr-x 1 wzk wzk 133 2006-01-04 01:25 test-handler.sh* -rw-r--r-- 1 wzk wzk 2350 2006-01-03 12:17 version.c -rw-r--r-- 1 wzk wzk 4530 2006-01-05 12:19 wcp.1 -rw-r--r-- 1 wzk wzk 25580 2006-01-05 14:00 wcp.c -rw-r--r-- 1 wzk wzk 4267 2006-01-05 15:13 wcpd.1 -rw-r--r-- 1 wzk wzk 1329 2006-01-02 19:47 wcp.h drwxr-xr-x 2 wzk wzk 4096 2006-01-05 16:39 zz-test/
By default the latest version is restored.
wcp's history command can be used to get some file history information.
# wcp history $HOME/zz-backup/wcp makefile 0004 2 654 Jan 05 15:15 makefile 0002 2 654 Jan 05 13:42 makefile
This means that there are two different versions of makefile. Both files have an equal size (we touch'ed the makefile before storing version #3) of 654 bytes and there are two hardlinks (second output column) to each of the files.
Let's restore version #2.
# wcp restore ~/zz-backup/wcp/ -n 0002 -v # . R ./check-copy R ./makefile # ./zz-test
The -n option selects the desired archive and the verbose option -v lists all files which are retrieved from the server. wcp gets only those files which need to be fetched to restore the requested version. Since all other files were not changed during this example they are the same in (the first restored) version #4 and #2.
Another feature when restoring files is
# ls -l makefile* -rw-r--r-- 1 wzk wzk 654 2006-01-05 13:42 makefile -rw-r--r-- 1 wzk wzk 654 2006-01-05 15:15 makefile~
that wcp creates '~'-backup files for existing files which are copied from the server, but only one level.
The history command has also on option to fetch files from the server.
# wcp history ~/zz-backup/wcp/ -r makefile 0004 2 654 Jan 05 15:15 makefile 0002 2 654 Jan 05 13:42 makefile # ls -l *makefile* -rw-r--r-- 1 wzk wzk 654 2006-01-05 13:42 0002+makefile -rw-r--r-- 1 wzk wzk 654 2006-01-05 15:15 0004+makefile -rw-r--r-- 1 wzk wzk 654 2006-01-05 13:42 makefile -rw-r--r-- 1 wzk wzk 654 2006-01-05 15:15 makefile~
The -r option tells wcp to fetch the various version that belong to the file from the server. Possible filename conflicts are solved by prefixing each restored file with it's version name.