I understand that there is resistance to adding dependencies to the tools package, so how about a contrib package for contributed tools? I have a neat snapshot script for my laptop that I wouldn''t mind sharing. Works mostly like the NetApp snapshots. Set up a cron job with a prefix for the snapshot name and the number of snapshots to keep. It''s very easy to set up for schemes like 24 hourly snapshots, 7 daily and 4 weekly. The only dependency as far as I remember now is bash. I would also be willing to try setting up a btrfs-to-btrfs incremental snapshot system given that my RFE #3 also gets done. :-) -- birger -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Le 03 août 2010 à 14:44, birger a écrit:> I have a neat snapshot script for my laptop that I wouldn''t mind > sharing. Works mostly like the NetApp snapshots. Set up a cron job with > a prefix for the snapshot name and the number of snapshots to keep. It''s > very easy to set up for schemes like 24 hourly snapshots, 7 daily and 4 > weekly.I have roughly the same thing in python. I can post it if someone is interested. Cheers, -- Xavier Nicollet -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello guys, I would be interested in that script, maybe in both of yours, Thank you! :) On Tue, Aug 3, 2010 at 15:48, Xavier Nicollet <nicollet@jeru.org> wrote:> > Le 03 août 2010 à 14:44, birger a écrit: > > I have a neat snapshot script for my laptop that I wouldn''t mind > > sharing. Works mostly like the NetApp snapshots. Set up a cron job with > > a prefix for the snapshot name and the number of snapshots to keep. It''s > > very easy to set up for schemes like 24 hourly snapshots, 7 daily and 4 > > weekly. > > I have roughly the same thing in python. I can post it if someone is > interested. > > Cheers, > > -- > Xavier Nicollet > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html-- To be or not to be -- Shakespeare | To do is to be -- Nietzsche | To be is to do -- Sartre | Do be do be do -- Sinatra -- To be or not to be -- Shakespeare | To do is to be -- Nietzsche | To be is to do -- Sartre | Do be do be do -- Sinatra -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Le 03 août 2010 à 15:42, Benjamin Griese a écrit:> Hello guys, > I would be interested in that script, maybe in both of yours,It is not supposedly bulletproof. Use at your own risks. backup1:/usr/local/bin# crontab -l # m h dom mon dow command # hourly backup 0 * * * * /usr/local/bin/snapshots.py -h # daily backup 10 6 * * * /usr/local/bin/snapshots.py -d # weekly backup #20 6 * * 0 /usr/local/bin/snapshots.py -w # monthly backup #30 6 1 * * /usr/local/bin/snapshots.py -m # yearly backup #40 6 1 1 * /usr/local/bin/snapshots.py -y #! /usr/bin/env python """ Daily snapshots for all our backups """ import os import os.path import glob import sys import subprocess import time import re def usage(): """ Print usage and exit """ print "usage: %s [-y|-m|-d|-h]" % sys.argv[0] sys.exit(2) def chdir_force(path): """ Chdir even if we have to make the path """ try: os.makedirs(path) except OSError: pass os.chdir(path) class Tuning: tuning = { ''-y'' : [ ''yearly'', 1 ], # we keep 1 snapshots ''-m'' : [ ''monthly'', 1 ], # we keep 1 snapshots ''-w'' : [ ''weekly'', 1 ], # we keep 1 weekly snapshots ''-d'' : [ ''daily'', 4 ], ''-h'' : [ ''hourly'', 2 ], } def __init__(self): try: option = sys.argv[1] (self.mode, self.keep) = Tuning.tuning[option] except (IndexError, KeyError): usage() def get_backup_name(): """ Return the backup dir name. It depends on the current location and time. """ name = time.strftime("backup-%y-%m-%d-%H:%M:%S") if os.path.exists(name): print "name already exists" sys.exit(2) return name def main(): tuning = Tuning() backup_path = os.path.join("/mnt/btrfs/history", tuning.mode) chdir_force(backup_path) # Make the new snapshot cmd = "/usr/local/bin/btrfs subvolume snapshot".split() backup_name = get_backup_name() cmd.extend( ["/backup/", backup_name] ) ret = subprocess.call(cmd) if ret != 0: print "return from btrfs subvol snap: " + str(ret) # Filter the number of snapshots files = sorted( (file for file in glob.glob( "backup-*") if not file.endswith(".old")) ) if len(files) > tuning.keep: for file in files[:-tuning.keep]: cmd = "/usr/local/bin/btrfs subvolume delete ".split() cmd.append( file ) ret = subprocess.call(cmd) if ret != 0: print "return from btrfs subvol del: " + ret if __name__ == ''__main__'': main() -- Xavier Nicollet -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
And none of them are what I would consider remotely useful for backups. (What, you guys don''t backup to external media?) :) Attached is my nightly backup script, edit it to suit, and dump a symlink into /etc/cron.daily or whatever. It requires a btrfs target (rather than source).