开发者

Tar archive: How reliable is append?

I noticed that the -a option in TAR allows appending files to an existing archive. How reliable is this for creating incremented backups of a set folder? Is there anyone here who can share their experiences?

From the TAR manual:

 -A, --catenate, --concatenate
       append tar files to an archive开发者_开发知识库


Since tar is a Tape Archive the last file will physically be appended to the archive, with an header. There is no index table which could cause issues.

Thus it's very reliable. Even if the process gets interrupted halfway you can seek the archive until the last complete entry and delete everything after it and everything will be as if you never tried to append to the archive.


As others have pointed out, tar really does append to the file, even if you just keep appending the same file to the tar ball:

makholm@korovyov:~$ dd if=/dev/urandom bs=1M count=1 of=./foo
1+0 records in
1+0 records out
1048576 bytes (1.0 MB) copied, 0.513785 s, 2.0 MB/s
makholm@korovyov:~$ for i in {1..5} ; do tar -rf foo.tar foo ; ls -lh foo.tar ; done
-rw-r--r-- 1 makholm makholm 1.1M 2011-01-22 01:07 foo.tar
-rw-r--r-- 1 makholm makholm 2.1M 2011-01-22 01:07 foo.tar
-rw-r--r-- 1 makholm makholm 3.1M 2011-01-22 01:07 foo.tar
-rw-r--r-- 1 makholm makholm 4.1M 2011-01-22 01:07 foo.tar
-rw-r--r-- 1 makholm makholm 5.1M 2011-01-22 01:07 foo.tar
makholm@korovyov:~$ 

This makes it pretty useless for something like incremental backups since your tarball will just grow with tons of duplicate files with each run...

Even cpio, which is generally a much more robust archiver does the same thing in this case.

If you want to do incremental backups, look into rsync and what it can do for you in terms of delta transfers and linking to previous versions of files...


Very reliable. tar doesn't store any information about the entries within the archive in the file header, so appending works fine. Just remember that append really does mean append, so any new entries with the same name as older ones will not remove the older entries from the archive.


As reliable as your hardware. Which is not.

Also, I am not sure it will replace.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜