Our sysadmin has created a backup system that creates snapshots of the hard drive.
When I try to restore an older version from the snapshot:
cp /path/to/snapshots/foo.bar /path/to/folder/foo.bar
I get an error:
cp: `/path/to/snapshots/foo.bar' and `/path/to/folder/foo.bar' are the same file.
I can delete the file and copy it but I wanted to know if there is a way to do this with cp.
I know that the files are not linked because:
- I can change the content of the source and the snapshots are kept unchanged (tested)
- I can delete the source and the snapshots are there to restore (tested)
- The files are stored on the university computation cluster. If something like that were true, somebody would have been fired already (or at least shouted at).
Nevertheless, the inode number of the files is the same
The cluster is implemented over red hat linux and I don't know what is the file system
df result:
Filesystem 1K-blocks Used Available Use% Mounted on
<ipadress>:/vol/hpc/storage
67633152 67633152 0 100% /storage
<ipadress>:/vol/hpc/storage
2186805248 982498048 1204307200 45% /storage
stat result:
File: `/path/to/snapshots/foo.bar'
Size: 404 Blocks: 8 IO Block: 4096 regular file
Device: 17h/23d Inode: 19750461 Links: 1
Access: (0644/-rw-r--r--) Uid: (<num1>/ yotama9) Gid: ( <num2>/ <groupname>)
Access: 2012-01-22 00:03:27.246852000 +0200
Modify: 2012-01-19 23:10:32.746397000 +0200
Change: 2012-01-19 23:10:32.746397000 +0200
File: `/path/to/folder/foo.bar'
Size: 404 Blocks: 8 IO Block: 4096 regular file
Device: 17h/23d Inode: 26335134 Links: 1
Access: (0644/-rw-r--r--) Uid: (<num1>/ yotama9) Gid: ( <num2>/ <groupname>)
Access: 2012-01-24 16:03:48.732453000 +0200
Modify: 2012-01-24 16:03:30.728900000 +0200
Change: 2012-01-24 16:03:30.728900000 +0200

run ls -l -ion both files to see if theinodenumber is the same. If the inode number is the same, then you do not have a backup; it means there is only 1 real file and 1 hard-link to that file, – Peter.O Jan 24 '12 at 14:08echo x >> foo.bar. Or test whether the inode is still the same after you change it your way. 2. That's the idea. You delete one link, the other one remains. – angus Jan 24 '12 at 15:08df /path/to/snapshot /path/to/source; ls -l /path/to/snapshot /path/to/source; stat /path/to/snapshot /path/to/sourceshow? – Gilles Jan 24 '12 at 19:13