LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-31-2016, 10:17 AM   #1
Defested
LQ Newbie
 
Registered: Mar 2015
Posts: 9

Rep: Reputation: Disabled
File level snapshots. Are they possible?


Hi,

I often deal with filesystem snapshots, usually LVM or ZFS. I have also had experience with linked clones and the like on the VMWare level.

Is it possible to take a snapshot of a single file? the scenario is such: my company has a shared network drive that is 2TB. on that 2TB, there is a 100GB file that I need to make a quick copy of. If I take a filesystem snapshot of it, the amount of changes happening on the rest of the network drive will quickly invalidate the snapshot's smaller size. Can I take a snapshot of a single file, for quick and dirty use, without affecting the source file?
 
Old 03-31-2016, 10:49 AM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,412

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
Yes, that's called "making a copy".
 
Old 03-31-2016, 11:46 AM   #3
Teufel
Member
 
Registered: Apr 2012
Distribution: Gentoo
Posts: 516

Rep: Reputation: 120Reputation: 120
Quote:
Originally Posted by descendant_command View Post
Yes, that's called "making a copy".
File may be changed (since it's a server and other users may access it) while copying in progress. So it will not be the same file that was initially copied.

To prevent the file from changes I'd lock it before copying and unlocked when copy operation finished:
Code:
chattr +i sourcefile
cp sourcefile destfile
chattr -i sourcefile
 
Old 03-31-2016, 04:53 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
Still won't prevent the file being changed if it is already open....
 
Old 04-04-2016, 05:45 PM   #5
joe_2000
Member
 
Registered: Jul 2012
Location: Aachen, Germany
Distribution: Void, Debian
Posts: 812

Rep: Reputation: 216Reputation: 216Reputation: 216
Quote:
Originally Posted by jpollard View Post
Still won't prevent the file being changed if it is already open....
How about taking a snapshot, copying the file from the snapshot and then removing the snapshot?
 
Old 04-04-2016, 06:14 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
The problem is that once the file is open, taking a snapshot may not catch the file from before it was open...

To do that would require a log structured filesystem. With a log structured filesystem the new file may be written, but it will be copied for the changes - or the changes will be in new blocks, with the original file remaining intact.
 
1 members found this post helpful.
Old 04-04-2016, 08:01 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 15,033

Rep: Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912Reputation: 1912
Take a rw snap, delete everything else from the snap. Just be *very* careful to only hit the snap.
 
Old 04-04-2016, 08:34 PM   #8
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.3, Oracle Linux, Mint
Posts: 9,669

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Quote:
Originally Posted by Defested View Post
Is it possible to take a snapshot of a single file?
It can't be done with LVM which works at the volume layer so has no concept of a file.

This feature is not implemented with ZFS either, although that should be something relatively simple to add.

On the other hand, it is already implemented with both btrfs and ocfs2 where file snapshots are created with a cp specific option :
Code:
cp --reflink original clone
Obviously, just like hard-links, this can work only if both the original and clone are on the same file system or btrfs volume.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Some beginner level file questions J.Doran Linux - Newbie 9 09-02-2013 09:16 AM
LVM snapshots in a file instead of wasting pre allocated space? browny_amiga Linux - General 6 03-28-2012 06:01 PM
replace a file in user level munna_dude Programming 1 09-02-2007 07:01 AM
replace a file in user level munna_dude Programming 6 09-01-2007 04:54 PM
emacs in run level 3 then switch to X (level 7) then back to level 3 dsoliver Slackware 3 09-01-2006 04:31 AM


All times are GMT -5. The time now is 10:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration