0

I have used this command on a big-sized (TB),constant changing directory with sub-folders and files.

$ tar c dir/* |gzip - | ssh user@host 'cd /dir/ && tar xz'

What would be the outcome at the end side?

Will it have only the files as of the start of tar?

ewwhite
  • 197,159
  • 92
  • 443
  • 809
pl1nk
  • 461
  • 5
  • 22

1 Answers1

1

From a test it seems that tar creates a filelist before continuing, so the end result will be that the files present when tar scanned the directories are the one transfered.

This is how I tested:

  • Created 2 large text files (around 3-400M each) called bigfile1 and bigfile2
  • Prepared a touch in another shell window, for a file called c-notsobigfile
  • began to tar the dir in which the files where and when it finished backing bigfile1 I fired the touch

This is my end result

tar czvf bigfiles.tar.tz test2/
a test2
a test2/bigfile
a test2/bigfile2

my c-notsobigfile was missing.

Frands Hansen
  • 4,657
  • 1
  • 17
  • 29
  • Give that even scanning the directory is not instant, this can result in an inconsistent mix of files compared to how applications are updating the directory tree. That's in addition to updates of file contents. If you want a consistent snapshot, use btrfs and let the application that makes updates do a volume snapshot, then tar the snapshot volume. It depends on how critical it is to be consistent. Ask the application designer. – Skaperen Aug 17 '12 at 13:23
  • If LVM is used that can be used to create snapshots as well. Actually that is quite a good idea. Make a snapshot, mount it and transfer the files form it. – Frands Hansen Aug 17 '12 at 13:28
  • If no LVM or brtfs is used how can someone find out the archived files at the instant that tar was started? So that later I can sync or use the mtime option. – pl1nk Aug 17 '12 at 15:08
  • @pl1nk take a look at rsync – user9517 Aug 17 '12 at 15:48
  • @Iain Sure, but still rsync will need to regenerate the whole structure. I have already started this tar approach. – pl1nk Aug 17 '12 at 16:06