我正在归档一个目录.此目录有一个由另一个进程写入的文件.当我使用Linux tar / Perl Tar模块对此进行tar时,在归档中文件的条目存在,但内容为null.
在tarring文件之前……
-rw-r--r-- 1 irraju dba 28 Feb 18 02:22 a
-rw-r--r-- 1 irraju dba 25 Feb 18 02:23 b
-rw-r--r-- 1 irraju dba 29 Feb 18 03:38 c
解开后
-rw-r--r-- irraju/dba 28 2009-02-18 02:22:58 a
-rw-r--r-- irraju/dba 25 2009-02-18 02:23:17 b
-rw-r--r-- irraju/dba 0 2009-02-18 03:33:12 c
我该如何解决这个问题?我希望文件在存档中包含存档时的内容.此文件可以是日志文件,并假设我们无法在tarring之前关闭文件句柄.
解决方法:
当您使用“Linux”标记问题时,您可能正在使用LVM分区.
如果您确实在LVM分区上运行,则可以使用LVM快照功能.
A wonderful facility provided by LVM is ‘snapshots’. This allows the administrator to create a new block device which presents an exact copy of a logical volume, frozen at some point in time. Typically this would be used when some batch processing, a backup for instance, needs to be performed on the logical volume, but you don’t want to halt a live system that is changing the data. When the snapshot device has been finished with the system administrator can just remove the device. This facility does require that the snapshot be made at a time when the data on the logical volume is in a consistent state – the VFS-lock patch for LVM1 makes sure that some filesystems do this automatically when a snapshot is created, and many of the filesystems in the 2.6 kernel do this automatically when a snapshot is created without patching.
标签:linux,perl,archive,tar
来源: https://codeday.me/bug/20190717/1485699.html