Using dar for backups
I have been persuaded to try “dar” for backups. This post describes my experience.
I had mostly been using tar for unix backups. For example, to backup my home partition, I would mount an external USB drive. Then I would “cd” to the directory on that drive where I wanted the backup to be stored. Next I set the shell variable “$x” to that directory.
Then I “cd” to the root directory and run tar to create the backup:
cd / tar zcf "$x"/homeaug2012.tgz home
Here I use quotes around the “$x” because the path sometimes has spaces in it. I chose a file name (“homeaug2012”) that is reasonably descriptive of the file, with a suffix “.tgz” for gzipped tar file. The path being backed up is “home”, and I use a relative path for that.
If I ever want to restore from that backup, I would use
cd / tar zxpf "$x"/homeaug2012.tgz
with the same prior definition of “$x”.
Why switch to dar?
I was persuaded by a commenter at opensuse forums, that I should instead try dar.
The main disadvantage of “tar”, is that a disk sector failure could corrupt the entire backup. This is particularly the case when using compression. With “dar”, the compression is done individually for each file, so that a damaged sector in the backup file should only damage one or two of the backed up files, and not overflow into damaging the entire archive.
On reading the man pages, I found another advantage of “dar”, namely that it supports an encrypted archive. I like this, because eventually that USB external drive will fail and be scrapped. And if everything sensitive is encrypted, then I am unlikely to have people going through scrap heaps and getting sensitive information from what they find.
There is one serious disadvantage of “dar” as compared to “tar”. Specifically, “dar” is not part of a standard linux install, and “dar” is usually not present on rescue boot CDs. That’s not a serious problem for me. I normally don’t backup my system partition. I only backup “/home”. If I ever need a full restore, I will first do a fresh install, and include “dar” in the software that is installed. And then I can use “dar” to recover the old home partition contents.
My experience with dar
I have done a few backups with “dar”. There’s an option to test the integrity of the created backup archive, so I usually use that option. Fortunately, I have not had any disk failures, so no need to run a recovery.
I did run a recovery a few days ago. It wasn’t due to a failed disk. It is that I was installing on new hardware, but wanted to use my old home directory. So I backed up the home partition on the old system, and restored on the new.
And that’s where I ran into problems. I had repeated errors in my attempts to restore.
Ignoring the compress and encrypt options for this description, what I in effect did was look at the file name for the backed up file. The file name ended in “.dar”. The man pages for “dar” say that a basename must be used in the argument. So, naturally, I used the path to the file, after removing that final “.dar”.
dar -x /path/to/file
Back came a message:
/path/to/file.1.dar is required for further operation, please provide the file.
I was unable to satisfy the command, so hit ESC to bail out. The resulting error message was:
Aborting program. User refused to continue while asking: /path/to/file.1.dar is required for further operation, please provide the file.
I googled parts of that error message. There were quite a few hits. It seemed that many people had the same problem. None of the pages that I consulted provided a solution.
I was about to give up, and repeat what I had done using “tar”. However, looking closely at the error message, I suddenly realized what was the problem. It was user error (i.e. my error).
Instead of removing “.dar” from the end of the filename to get the basename, I should have removed “.1.dar”.
Once I fixed that, the recovery worked very well.
With luck, future people running into that problem might see this post in their google search results, giving them a solution.