Why does amrecover erase files?

From The Open Source Backup Wiki (Amanda, MySQL Backup, BackupPC)

Jump to: navigation, search

This article is a part of the Troubleshooting collection.


When you run amrecover to restore a directory, files which existed before the recovery are gone afterward


To avoid accidents like these, restore into a temporary directory, and move the files to the correct location after inspection.


Amrecover restores to the state of the data as of a particular date, i.e. the state of the data at the time of the dump on that date. When you restore a file, that is what you expect, but when you restore a directory, the state of the directory is restored, meaning that files that were not there at that time will be erased.

$ ls /home/luser/nobelprizedata
file1 file3

Oops, missing file2, let's restore that from the backup...

$ cd /
$ sudo amrecover daily
AMRECOVER Version 2.4.5. ...
200 Disk set to /.
amrecover> setdate 2005-04-01
200 Working date set to 2005-04-01.
amrecover> cd home/luser/nobelprizedata
amrecover> ls
2005-04-01 .
2005-04-01 file1
2005-04-01 file2

At that time only two files existed. We ask to restore the directory:

amrecover> add .
amrecover> extract
[...Load tape etc. etc....]
amrecover> exit
$ ls
file1 file2

And notice file3 is gone. And file1 is replaced with older data too, maybe not what was intended either.

Note that the amrecover command " add * " ALSO add the current directory "." to the extraction list (contrary to the shell "*" glob), leading to the same problem as above!

When the restore process asks many tapes -- first level 0, followed by restore from level 1, follow by restore from level 2, etc. -- you may notice the same behaviour. Files are created, and removed again, indicating that the file existed when the level 0 backup was created, and did not exist anymore when a higher level backup was made. A weird side effect here can occur when the level 0 dump of the directory contained a very large file, that was removed when the level 1 dump was made: you can run out of diskspace trying to restore a 20Kbyte directory.

To get finer control over the restore process, you can always use amrestore(8) and pipe the output into the restore program, with the options you prefer and tuned for the case.

Even backups made with gnutar have this behaviour! Gnutar has many more features than tar programs from some vendors.

Personal tools