Restore Some Files

Back to RequestsForEnhancement

sftp and scp do not preserve numeric UID/GID (user id and group id). If the backup server uses different number-to-name mappings, then a single file restore performed manually by the sysadmin will put files back with the wrong user and group.

rsync will put files back with the right numeric UID/GID/permissions (except for symlinks). However, it requires a lot of command line options, and it uses a matching pattern format that differs from Perl regular expressions (such as you might use in dirvish-locate). The paths also get very long.

I propose a Perl program, dirvish-file-restore, which restores single files, given a vault, a date, and a file path. That will be followed by a more sophisticated Perl program that can restore file trees matching a pattern.

Restored files are restored to a new name, which is the original name with the backup date and time appended, for example foo.c_2005_0316_0300 . We may also make the restore prefix optionally null, so files can be replaced.

2004 December 21 KeithLofstrom


rsync can restore a file, like so:

 $src=/backup/dirvish/client/clienthome/2004-1226-0300/tree/home/keithl/foo.c
 $des=client:/home/keithl/foo.c-2004-1226-0300                                                                               
 rsync -vvrltHpgoDx --numeric-ids $src $des

This restores the file foo.c with a copy foo.c-2004-1226-0300, leaving the current foo.c intact. The script runs very quickly.

If $src points to a directory, then a directory will be created on the client with name $des and the restored directory will be placed inside it. For example,

 $src=/backup/dirvish/client/clienthome/2004-1226-0300/tree/home/keithl/somedir
 $des=client:/home/keithl/somedir-2004-1226-0300                                                                               
 rsync -vvrltHpgoDx --numeric-ids $src $des

Then there will be a directory on the client named /home/keithl/somedir-2004-1226-0300 and it will contain the directory somedir and its contents .

So, how to design dirvish-file-restore?

I plan to build a very simple perl program with these command line arguments:

 dirvish-file-restore                \      # synonym dfr
    --image   client-2004-1226-0300  \      # for example, a branch
    --vault   clienthome             \
              /home/keithl/somedir          #

... that does something like the above. I will use DirvishLib.pm (refactored dirvish.pl) to find the configuration data that locates the backups. If command line arguments are missing, the program will ask the user; in that case it will also say what it is going to do and ask for permission to complete.

Note that dirvish cannot restore symbolic link times. Also, links across file system boundaries or outside of a restored file tree may be left unconnected. See SymbolicLinkDates for the reason why.

2004 December 26 KeithLofstrom


Comments? Please enter date and WikiName.

Dirvish wiki: RestoreSomeFiles (last edited 2011-01-24 06:46:40 by KeithLofstrom)