public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] snapper (btrfs)
@ 2014-09-24 15:07 James
  2014-09-24 18:37 ` Rich Freeman
  0 siblings, 1 reply; 6+ messages in thread
From: James @ 2014-09-24 15:07 UTC (permalink / raw
  To: gentoo-user

Hello,

At the bottom of this link:

http://www.linux.com/learn/tutorials/767683-how-to-create-and-manage-btrfs-snapshots-and-rollbacks-on-linux-part-2

It says: " Snapper is a fabulous graphical Btrfs manager. There are packages
for other RPM distros and some Debian and Xubuntu packages "


In portage we have : app-backup/snapper

Homepage:            http://snapper.io/
Description:         Command-line program for btrfs and ext4 snapshot management


But the link (snapper.io) is about backups.

Anyone used "snapper" for btrfs management? 
If os, do you like "snapper" for btrfs management?

If so, did you use the portage "snapper" or an overlay?


curiously,
James



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] snapper (btrfs)
  2014-09-24 15:07 [gentoo-user] snapper (btrfs) James
@ 2014-09-24 18:37 ` Rich Freeman
  2014-09-24 21:11   ` Neil Bothwick
  0 siblings, 1 reply; 6+ messages in thread
From: Rich Freeman @ 2014-09-24 18:37 UTC (permalink / raw
  To: gentoo-user

On Wed, Sep 24, 2014 at 11:07 AM, James <wireless@tampabay.rr.com> wrote:
>
> Anyone used "snapper" for btrfs management?
> If os, do you like "snapper" for btrfs management?
>
> If so, did you use the portage "snapper" or an overlay?
>

I use snapper from portage.  Snapper itself works just fine.  I've
found that trying to integrate it into portage (before/after snapshots
on every emerge) is just way too much overhead (it goes fast, but you
end up with a bazillion snapshots).  Also, I've had deadlock problems
with deleting multiple snapshots at once, which is certainly a kernel
problem.  So, right now I'm using snapper to manage snapshots but I do
not use time/event-based snapshots at all - I just create them when
needed and clean them up manually, and carefully.

--
Rich


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] snapper (btrfs)
  2014-09-24 18:37 ` Rich Freeman
@ 2014-09-24 21:11   ` Neil Bothwick
  2014-09-25  8:22     ` Thanasis
  2014-09-26 19:53     ` [gentoo-user] " James
  0 siblings, 2 replies; 6+ messages in thread
From: Neil Bothwick @ 2014-09-24 21:11 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

On Wed, 24 Sep 2014 14:37:52 -0400, Rich Freeman wrote:

> I use snapper from portage.  Snapper itself works just fine.  I've
> found that trying to integrate it into portage (before/after snapshots
> on every emerge) is just way too much overhead (it goes fast, but you
> end up with a bazillion snapshots).  Also, I've had deadlock problems
> with deleting multiple snapshots at once, which is certainly a kernel
> problem.  So, right now I'm using snapper to manage snapshots but I do
> not use time/event-based snapshots at all - I just create them when
> needed and clean them up manually, and carefully.

I use a home-brewed script to make time based snapshots, called from
cron - a little like zfs-auto-snapshot. I set a limit on the number of
each type of snapshot so the script generally creates one snapshot and
deletes one snapshot for each subvolume whenever it is called, avoiding
the need to ever have a gazillion snapshots to delete.


-- 
Neil Bothwick

Everything else being equal, fat people use more soap.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] snapper (btrfs)
  2014-09-24 21:11   ` Neil Bothwick
@ 2014-09-25  8:22     ` Thanasis
  2014-09-25 20:40       ` Neil Bothwick
  2014-09-26 19:53     ` [gentoo-user] " James
  1 sibling, 1 reply; 6+ messages in thread
From: Thanasis @ 2014-09-25  8:22 UTC (permalink / raw
  To: gentoo-user

on 09/25/2014 12:11 AM Neil Bothwick wrote the following:

> I use a home-brewed script to make time based snapshots, called from
> cron - a little like zfs-auto-snapshot. I set a limit on the number of
> each type of snapshot so the script generally creates one snapshot and
> deletes one snapshot for each subvolume whenever it is called, avoiding
> the need to ever have a gazillion snapshots to delete.
>
>
Do you mind sharing the script please?


------------------------------------------------------------------------
    “You are forgiven for your happiness and your successes only if you 
  generously consent to share them.”
    ― Albert Camus


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-user] snapper (btrfs)
  2014-09-25  8:22     ` Thanasis
@ 2014-09-25 20:40       ` Neil Bothwick
  0 siblings, 0 replies; 6+ messages in thread
From: Neil Bothwick @ 2014-09-25 20:40 UTC (permalink / raw
  To: gentoo-user


[-- Attachment #1.1: Type: text/plain, Size: 759 bytes --]

On Thu, 25 Sep 2014 11:22:15 +0300, Thanasis wrote:

> > I use a home-brewed script to make time based snapshots, called from
> > cron - a little like zfs-auto-snapshot. I set a limit on the number of
> > each type of snapshot so the script generally creates one snapshot and
> > deletes one snapshot for each subvolume whenever it is called,
> > avoiding the need to ever have a gazillion snapshots to delete.

> Do you mind sharing the script please?

Attached. There are two things about it that I can state with certainty.

1) It works for me.

2) It may or may not work for you.

You need to set the location of your snapshots at the top of the script.


-- 
Neil Bothwick

Those who live by the sword get shot by those who don't.

[-- Attachment #1.2: buttersnap --]
[-- Type: application/octet-stream, Size: 2149 bytes --]

#!/bin/env python

import argparse, os, socket, subprocess, sys, time

snapshot_dir = '/snapshots'

parser = argparse.ArgumentParser(description='Manage automatic snapshots of btrfs volumes')
parser.add_argument('paths', nargs='*', help='Paths to back up - use // for all volumes')
parser.add_argument('-v', '--verbose', help='Print each command before it is run', action='store_true')
parser.add_argument('-p', '--pretend', help='Only show what would be done', action='store_true')
parser.add_argument('-l', '--label', default="single", help='Type of snapshot: hourly, daily, weekly, monthly, single')
parser.add_argument('-k', '--keep', type=int, help='How many snapshots of this frequency to keep')
parser.add_argument('-C', '--cleanonly', help='Onlty clean up old snapshots', action='store_true')
args = parser.parse_args()

def run_command(command):
    if args.pretend:
        print 'Would run:', ' '.join(command)
        return
    if args.verbose:
        print 'Running:', ' '.join(command)
	try:
		subprocess.check_output(command)
	except CalledProcessError:
		print 'An error ocurred running %s\n%s' %(' '.join(command), subprocess.CalledProcessError.output)

def set_dest(path):
    if path == '/':
        dest = snapshot_dir + '/root'
    else:
        dest = os.path.join(snapshot_dir, os.path.basename(path.rstrip('/')))

    if not os.path.isdir(dest):
        os.mkdir(dest)
    return dest

if os.getuid() != 0:
	print '%s must be run as root' % os.path.basename(sys.argv[0])
	sys.exit(1)

if not args.cleanonly:
    for path in args.paths:
        dest_dir = set_dest(path)
        snapshot = '%s/%s_%s' % (dest_dir, args.label, time.strftime('%Y-%m-%d_%H%M', time.gmtime()))
        run_command(['btrfs', 'subvolume', 'snapshot', '-r', path, snapshot])

if args.keep:
    for path in args.paths:
        dest_dir = set_dest(path)
        snapshots = filter(lambda x: x.startswith(args.label), os.listdir(dest_dir))
        if len(snapshots) <= args.keep:
            continue

        snapshots.reverse()
        run_command(['btrfs', 'subvolume', 'delete'] + map(lambda x: os.path.join(dest_dir, x),  snapshots[args.keep:]))

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [gentoo-user] Re: snapper (btrfs)
  2014-09-24 21:11   ` Neil Bothwick
  2014-09-25  8:22     ` Thanasis
@ 2014-09-26 19:53     ` James
  1 sibling, 0 replies; 6+ messages in thread
From: James @ 2014-09-26 19:53 UTC (permalink / raw
  To: gentoo-user

Neil Bothwick <neil <at> digimed.co.uk> writes:


> > I use snapper from portage.  Snapper itself works just fine.  

Good to know

> > found that trying to integrate it into portage (before/after snapshots
> > on every emerge) is just way too much overhead (it goes fast, but you
> > end up with a bazillion snapshots).  Also, I've had deadlock problems
> > with deleting multiple snapshots at once, which is certainly a kernel
> > problem.  

Also very good to know.
Ftrace/trace-cmd/kernelshark surely would be great to use for this.

http://zougloub.eu/overlay/sys-kernel/trace-cmd/

I have not tested this yet..............


> > So, right now I'm using snapper to manage snapshots but I do
> > not use time/event-based snapshots at all - I just create them when
> > needed and clean them up manually, and carefully.

Well my setup is going to be (2) 2T sata-3 drives in a mirrored
configuration. So yea, manual will porbably be just fine for me too.


> I use a home-brewed script to make time based snapshots, called from
> cron - a little like zfs-auto-snapshot. I set a limit on the number of
> each type of snapshot so the script generally creates one snapshot and
> deletes one snapshot for each subvolume whenever it is called, avoiding
> the need to ever have a gazillion snapshots to delete.


Sounds good. I grabbed a copy. I drop you a line, if I run into
troubles using buttersnap.


cheers,
James







^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-26 19:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-24 15:07 [gentoo-user] snapper (btrfs) James
2014-09-24 18:37 ` Rich Freeman
2014-09-24 21:11   ` Neil Bothwick
2014-09-25  8:22     ` Thanasis
2014-09-25 20:40       ` Neil Bothwick
2014-09-26 19:53     ` [gentoo-user] " James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox