Skip to contentSkip to conversation

BTRFS send: exclude directories

DISCUSSION GEO 3 participants 3 messages Feb 16, 2014 Btrfs file system

lore
Share & tools
lore

GEO

author
#0 lore raw

Hi,

I have been experimenting with btrfs send/receive for incremental backups, but could not figure out how to exclude certain directories from subvolumes/snapshots. For example, I want to backup my data in home, but I am not interested in backing up hidden directories like .cache too. Is it currently possible to achieve something like that?

Thanks for the great work!

#1 lore raw
Quoted 8 lines · GEO

Hi,

I have been experimenting with btrfs send/receive for incremental backups, but could not figure out how to exclude certain directories from subvolumes/snapshots. For example, I want to backup my data in home, but I am not interested in backing up hidden directories like .cache too. Is it currently possible to achieve something like that?

Quoted 5 lines

Thanks for the great work!
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Hi,

You could create a read-write snapshot, remove the directories that you're not interested in, then create a read-only snapshot of that to send, then remove the read-write snapshot.

Note that I've not tested this myself, so I can't guarantee that it will work. (It makes sense in my head though!)

Cheers,

WorMzy

(apologies if you receive this twice, I just noticed that gmail doesn't reply to this mailing list, it replies to the person directly)

#2 lore raw
In reply to GEO

Simplest way to do it is to make the directories that you don't want to replicate be separate subvolumes. I do this to keep from replicating copies of snapshot directories.

Example:

mv /home/GEO/.cache /home/GEO/.cache.tmp
btrfs sub create /home/GEO/.cache
cp -a --reflink=always /home/GEO/.cache.tmp/ /home/GEO/.cache/ cp -a --reflink=always /home/GEO/.cache.tmp/.* /home/GEO/.cache/ rm -rf /home/GEO/.cache.tmp

You could also just mv the files instead of first doing cp and then rm'ing them, but if you have many gigs of files, the cp --reflink=always will be a win - currently (at least, last I checked) mv across subvolumes would actually do a full copy, whereas a cp --reflink=always will just create new pointers to the blocks in the appropriate place (thereby completing instantaneously).

Anyway, once .cache (or whatever) is a subvolume instead of a directory, it will no longer get replicated with your btrfs send command of its parent directory.

Quoted 13 lines · GEO

Hi,

I have been experimenting with btrfs send/receive for incremental backups, but could not figure out how to exclude certain directories from subvolumes/snapshots. For example, I want to backup my data in home, but I am not interested in backing up hidden directories like .cache too. Is it currently possible to achieve something like that?

Thanks for the great work!
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html