Skip to contentSkip to conversation

snaprotate

DISCUSSION Ulli Horlacher 1 participant 3 messages Dec 2, 2017 – Apr 25 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Being a Netapp user for a long time, I have always missed btrfs snapshots the way Netapp creates them.

I have now written snaprotate:

http://fex.belwue.de/snaprotate.html

snaprotate creates and manages btrfs readonly snapshots similar to Netapp. Snapshots have names like hourly, daily, weekly, single and a date_time prefix.

Snapshots are stored in a .snapshot/ directory in the subvolume root.
Example: /local/home/.snapshot/2017-09-09_1200.hourly

You create a snapshot with:

snaprotate <class> <count> <subvol>

<class> is your snapshot name
<count> is the maximum number of snapshots for this class <subvol> is the btrfs subvolume directory you want to snapshoot

If count is exceeded then the oldest snapshot will be deleted.

You can use snaprotate either as root or as normal user (for your own subvolumes).

Example usages:

snaprotate single 3 /data # create and rotate "single" snapshot
snaprotate test 0 /tmp # delete all "test" snapshots
snaprotate daily 7 /home /local/share # create and rotate "daily" snapshot
snaprotate -l /home # list snapshots

Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<[email protected]>
#1 lore raw
Quoted 6 lines · Ulli Horlacher

Being a Netapp user for a long time, I have always missed btrfs snapshots the way Netapp creates them.

I have now written snaprotate:

http://fex.belwue.de/snaprotate.html

Uuuppps.. just found, I have posted this 2017-09-09 already! Sorry for the duplicate!

But the documentation now is better :-)

Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<[email protected]>
#2 lore raw
In reply to Ulli Horlacher

For what and when do you need a backup?
In most cases it is an inadvertently deleted or overwritten file. Catastrophic failures like a filesystem crash or a burned computer are more seldom.
For the first case one wants a QUICK and EASY way to restore the lost file(s). btrfs snapshots comes to mind :-)

Quoted 5 lines · Ulli Horlacher

Being a Netapp user for a long time, I have always missed btrfs snapshots the way Netapp creates them.

I have now written snaprotate:

Quoted 8 lines

http://fex.belwue.de/snaprotate.html

snaprotate creates and manages btrfs readonly snapshots similar to Netapp. Snapshots have names like hourly, daily, weekly, single and a date_time prefix.

Snapshots are stored in a .snapshot/ directory in the subvolume root.
Example: /local/home/.snapshot/2017-09-09_1200.hourly

Some time later...

I have extended snaprotate with the shell function ssd (snapshot directories).

With ssd one can interactivly select a snapshot directory for recovery. Example:

framstag@fex:~/data: ssd
Snapshots:
#1) 2026-04-18_1100
#2) 2026-04-18_1000
#3) 2026-04-18_0900
#4) 2026-04-18_0800
#5) 2026-04-18_0700
#6) 2026-04-18_0600
#7) 2026-04-18_0500
#8) 2026-04-18_0400
#9) 2026-04-18_0300
#10) 2026-04-18_0200
#11) 2026-04-18_0100
#12) 2026-04-18_0000
#13) 2026-04-17_2300
#14) 2026-04-17_0000
#15) 2026-04-16_0000
#16) 2026-04-13_0000
Snapshot #3
SS0=/home/framstag/data framstag@fex:/local/home/.snapshot/2026-04-18_0900.hourly/framstag/data:

The only thing I have had to enter was "3"
Then I am in the snapshot directory from 2026-04-18 09:00 The restore then can be done with any command, example:

framstag@fex:/local/home/.snapshot/2026-04-18_0900.hourly/framstag/data: cp -av *.txt $SS0/ framstag@fex:/local/home/.snapshot/2026-04-18_0900.hourly/framstag/data: cd - framstag@fex:~/data:

https://fex.belwue.de/linuxtools/snaprotate.html

Signature · 6 lines
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart         E-Mail: [email protected]
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    https://www.tik.uni-stuttgart.de/
REF:<[email protected]>