0

I searched the web but did not find any info about this. I'm mounting an LVM snapshot and I notice the timestamps of the files there keep changing. I though LVM snapshot was a one time freeze in time w/ write on copy of the original partition, so the timestamps should not change.

Of course now tar is giving me an error saying the "file changed as we read it" which I think comes from the timestamps being changed.

Any insights?

sysadmin1138
  • 133,124
  • 18
  • 176
  • 300
Ricardo
  • 170
  • 1
  • 1
  • 5
  • Are you saying that you mount a snapshot under, e.g., /mnt and then create a tarball of /mnt filesystem during which you get the "file changed as we read it?" – Mark Wagner Oct 25 '10 at 22:08
  • yes, exactly, do timestamps of snapshot files change? – Ricardo Oct 25 '10 at 22:38

3 Answers3

1

The snapshot will keep changing. The underlying filesystem will not. Make backups from that instead.

Ignacio Vazquez-Abrams
  • 45,939
  • 6
  • 79
  • 84
  • I dont understand. I can i make a backup from the filesystem without having to mount the snapshot in /mnt – Ricardo Oct 25 '10 at 22:39
  • You don't mount the snapshot in `/mnt`. You mount the snapshot where you normally would, and you mount the underlying filesystem read-only in `/mnt`. – Ignacio Vazquez-Abrams Oct 26 '10 at 02:36
  • still dont get it. im using the procedure for backups as explained here: http://www.mysqlperformanceblog.com/2006/08/21/using-lvm-for-mysql-backup-and-replication-setup/ – Ricardo Oct 26 '10 at 02:38
  • That article has it backwards. Mount the snapshot in place, and backup the underlying filesystem. – Ignacio Vazquez-Abrams Oct 26 '10 at 02:39
  • but the underlying filesystem is changing cause the tables are unlocked... thats the all purpose of having the snapshot, to avoid table locking for more than n seconds – Ricardo Oct 26 '10 at 02:48
  • Wait, that article is from 2006. That means that it would be using LVM1. Are you sure that *you're* using LVM1? It certainly sounds to me as though you're using LVM2. – Ignacio Vazquez-Abrams Oct 26 '10 at 02:51
  • @Ignacio - I don't understand your answer. The whole idea of LVM snapshots (like other types of snapshot) is to provide a frozen, point-in-time view of the original LV. The LVM HOWTO confirms that's how things work: http://tldp.org/HOWTO/LVM-HOWTO/snapshotintro.html - LVM1 had read-only snapshots, while LVM2 has read-write as well (so you can clone and then do something to the filesystem). – RichVel Sep 01 '11 at 06:45
0

So apparently lvm1 timestamps the mtime on files instead of the snapshot creation time: http://www.redhat.com/archives/linux-lvm/2005-April/msg00039.html

this explains why tar is complaining. Any way i can make tar ignore this?

Ricardo
  • 170
  • 1
  • 1
  • 5
0

To ensure that no one can write to your snapshot while you run your backup, try mounting it read-only:

mount -o ro <snapshot-device> /mnt

EDIT

If the snapshot is already mounted, try this instead:

mount -o remount,ro <snapshot-device> /mnt
Steven Monday
  • 13,599
  • 4
  • 36
  • 45
  • it's giving me a mount error "already mounted" if i give that option. besides how would the timestamps be updated if it's read only? – Ricardo Oct 26 '10 at 02:49
  • I updated my answer. Please try the `remount` option. I don't understand the rest of your comment. What timestamps do you think should be updated? – Steven Monday Oct 26 '10 at 03:23