• Stars
    star
    220
  • Rank 174,473 (Top 4 %)
  • Language
    Python
  • License
    BSD 2-Clause "Sim...
  • Created almost 14 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

tarsnap wrapper which expires backups using a gfs-scheme.

Tarsnapper

A wrapper around tarsnap which does two things:

  • Lets you define "backup jobs" (tarsnap invocations) in a config file, though on it's own this has little advantage over just using a a shell script.

  • The ability to expire old backups using a Grandfather-father-son backup scheme. This feature can be used in conjunction with tarsnapper backup jobs, or standalone, to be applied to any existing set of tarsnap backup archives, regardless of how they have been created.

Installation

Using pip:

$ pip install tarsnapper

Making a single backup without a configuration file

tarsnapper --target foobar-\$date --sources /etc/  --deltas 6h 7d 31d - make

This will backup the /etc/ folder every time you call this command (put it in cron, for example), and after each backup made, attempts to expire old backups to match the deltas given.

Note the following:

  • You need to give the $date placeholder for expiration to work, and you will need to escape the dollar sign in your shell.

  • You need to end the list of deltas with a - character.

  • tarsnap needs to be setup on your machine correctly, that is, tarsnap needs to be able to find it's keyfile and so on via tarsnap.conf. The ability to pass through options to tarsnap via the tarsnapper CLI exists, though.

Using a configuration file

We also support a configuration file. It allows multiple jobs to be defined, and has more feature, such as pre-/post job commands. It looks like this:

# Global values, valid for all jobs unless overridden:
# A job's delta controls when old backups are expired
# (see "How expiring backups works" below)
deltas: 1d 7d 30d
# You can avoid repetition by giving deltas names
delta-names:
  super-important: 1h 1d 30d 90d 360d
# A job's target sets the name of the created archive
target: /localmachine/$name-$date
# You can also include jobs from separate files
include-jobs: /usr/local/etc/tarsnapper/*.yml

jobs:
  # define a job called images (names must be unique)
  images:
    source: /var/lib/mysql
    exclude: /var/lib/mysql/temp
    exec_before: service mysql stop
    exec_after: service mysql start
    # Aliases can be used when renaming a job to match old archives.
    alias: img

  some-other-job:
    sources:
      - /var/dir/1
      - /etc/google
    excludes:
      - /etc/google/cache
    target: /custom-target-$date.zip
    deltas: 1h 6h 1d 7d 24d 180d

For the images job, the global target will be used, with the name placeholder replaced by the backup job name, in this case images.

You can then ask tarsnapper to create new backups for each job:

$ tarsnapper -c myconfigfile make

The name of the archive will be the target option, with the $date placeholder replaced by the current timestamp, using either the dateformat option, or %Y%m%d-%H%M%S.

Or to expire those archives no longer needed, as per the chosen deltas:

$ tarsnapper -c myconfigfile expire

If you need to pass arguments through to tarsnap, you can do this as well:

$ tarsnapper -o configfile tarsnap.conf -o v -c tarsnapper.conf make

This will use tarsnap.conf as the tarsnap configuration file, tarsnapper.conf as the tarsnapper configuration file, and will also put tarsnap into verbose mode via the -v flag.

Using the include-jobs option, you could insert 1 or more jobs in (for example) /usr/local/etc/tarsnapper/extra-backup-jobs.yml:

# Included jobs act just like jobs in the main config file, so for
# example the default target is active and named deltas are
# available, and job names must still be globally unique.
yet-another-job:
  source: /var/dir/2
  deltas: 1h 1d 30d

an-important-job:
  source: /var/something-important
  delta: super-important

include-jobs uses Python's globbing to find job files and hence is subject to the limitations thereof.

Expiring backups

Note that if you're running tarsnapper with make, it will implicitly expire backups as well; there is no need to run make AND expire both.

If you want to create the backups yourself, and are only interested in the expiration functionality, you can do just that:

$ tarsnapper --target "foobar-\$date" --deltas 1d 7d 30d - expire

The --target argument selects which set of backups to apply the expire operation to. All archives that match this expression are considered to be part of the same backup set that you want to operate on.

tarsnapper will then look at the date of each archive (this is why you need the $date placeholder) and determine those which are not needed to accommodate the given given delta range. It will parse the date using the python-dateutil library, which supports a vast array of different formats, though some restrictions apply: If you are using yyyy-dd-mm, it cannot generally differentiate that from yyyy-mm-dd.

You can specify a custom dateformat using the --dateformat option, which should be a format string as expected by the Python strptime function (e.g. %Y%m%d-%H%M%S). Usually, a custom format is not necessary.

Note the single "-" that needs to be given between the --deltas argument and the command.

The expire command supports a --dry-run argument that will allow you to see what would be deleted:

$ tarsnapper --target "foobar-\$date" --deltas 1d 7d 30d - expire --dry-run

How expiring backups works

The design goals for this were as follows:

  • Do not require backup names to include information on which generation a backup belongs to, like for example tarsnap-generations does. That is, you can create your backups anyway you wish, and simply use this utility to delete old backups.

  • Do not use any fixed generations (weekly, monthly etc), but freeform timespans.

  • Similarily, do not make any assumptions about when or if backup jobs have actually run or will run, but try to match the given deltas as closely as possible.

The generations are defined by a list of deltas. 60s means a minute, 12h is half a day, 7d is a week. The number of backups in each generation is implied by it's and the parent generation's delta.

For example, given the deltas 1h 1d 7d, the first generation will consist of 24 backups each one hour older than the previous (or the closest approximation possible given the available backups), the second generation of 7 backups each one day older than the previous, and backups older than 7 days will be discarded for good.

The most recent backup is always kept.

As an example, here is a list of backups from a Desktop computer that has often been running non-stop for days, but also has on occasion been turned off for weeks at a time, using the deltas 1d 7d 30d 360d 18000d:

  dropbox-20140424-054252
  dropbox-20140423-054120
  dropbox-20140422-053921
  dropbox-20140421-053920
  dropbox-20140420-054246
  dropbox-20140419-054007
  dropbox-20140418-060211
  dropbox-20140226-065032
  dropbox-20140214-063824
  dropbox-20140115-072109
  dropbox-20131216-100926
  dropbox-20131115-211256
  dropbox-20131012-054438
  dropbox-20130912-054731
  dropbox-20130813-090621
  dropbox-20130713-160422
  dropbox-20130610-054348
  dropbox-20130511-055537
  dropbox-20130312-064042
  dropbox-20120325-054505
  dropbox-20110331-12174

More Repositories

1

webassets

Asset management for Python web development.
Python
917
star
2

flask-assets

Flask webassets integration.
Python
443
star
3

onkyo-eiscp

Control Onkyo A/V receivers over the network; usuable as a script, or as a Python library.
Python
442
star
4

k8s-snapshots

Automatic Volume Snapshots on Kubernetes.
Python
348
star
5

android-autostarts

Tool to manage autostarts (broadcast receivers) on an Android device.
Java
195
star
6

android2po

Convert Android string resources to gettext, and back.
Python
125
star
7

python-glob2

Version of the glob module that supports recursion via **, and can capture patterns.
Python
123
star
8

django-assets

Django webassets integration.
Python
89
star
9

android-platform_sdk

To keep the deprecated apkbuilder tool alive should it break.
Java
64
star
10

gitolite-simple-mirror

post-receive hook to do make mirroring with gitolite easy.
Shell
54
star
11

ripple-python

Ripple-related routines in Python. Might become a proper client library later.
Python
49
star
12

py-androidbuild

Routines to build an Android app in Python and to get rid of Ant.
Python
46
star
13

sendtokindle

Grahical Send to Kindle Utility for Ubuntu
Python
45
star
14

dockerfiles

Some of my dockerfiles.
Dockerfile
43
star
15

ntfslink

A set of Windows Shell Extensions, providing extended functionality for creating and using hard links and junction points on NTFS file systems.
Pascal
42
star
16

linuxutils

Stuff I use on Linux.
Python
30
star
17

react-arrow

React component that renders a SVG arrow. Can point in any direction, different styles.
JavaScript
19
star
18

wasmbind

Nicer Python interface to Webassembly modules.
Python
17
star
19

elrc-maker

Tool to create Enhanced LRC files.
JavaScript
15
star
20

android-remote-stacktrace

Fork of android-remote-stacktrace to fit my personal needs.
Java
13
star
21

mfcobol-export

Exporter for Microfocus COBOL databases.
Python
13
star
22

python-closure

Closure compiler packaged for Python
Python
12
star
23

sonosweb

Import of purple.org/sonos
Perl
12
star
24

ripple-sepa-bridge

Python
12
star
25

emma

Import of "emma - extendable MySQL managing assistant"
Python
12
star
26

feedplatform

FeedPlatform implements the core functionality of a feed aggregator. It is supposed to be reusable and extremely flexible, mainly intended for integration with other applications.
Python
10
star
27

janos

Java-based Sonos Controller (SVN import from http://sourceforge.net/projects/janos/)
Java
10
star
28

django-tables

Deprecated in favor of django-tables2. This exists to keep old urls working.
Python
9
star
29

sorl-thumbnail

Python
9
star
30

xappy

Python
8
star
31

trio-asgi-server

Python
8
star
32

python-akismet

The voidspace.org.uk Akismet Python library with some fixes.
Python
8
star
33

python-multiprocessing

With patch for #18, to make it usable with celery.
7
star
34

synology-sipgate-sms

Send SMS notifications on Synology NAS via Sipgate.
Python
7
star
35

trio-protocol

Run asyncio protocols on top of trio
Python
7
star
36

docker-gitolite

Shell
7
star
37

jmap-python

A JMAP library in Python.
Python
6
star
38

influx-sansio

Python
6
star
39

ripple2go

Compiled version of the ripple client that runs on Github Pages. Fork the repository to get your own.
JavaScript
6
star
40

gevent-erlang-mode

Ad hoc, informally-specified, bug-ridden, slow implementations of some Erlang-style concepts in gevent.
Python
6
star
41

pysieved

The original branch seems to be broken with the git client in etch stable
Python
6
star
42

rsnapgraph

git import of rsnapgraph; Make it work with gnuplot 4.4
Perl
5
star
43

ripple-wcg-badges

HTML
5
star
44

openinghours.js

Query schema.org OpeningHoursSpecification in JavaScript.
TypeScript
5
star
45

allthekeeps

Explorer for the Keep and TBTC networks.
TypeScript
5
star
46

wifilock

Android App, ensures that the Wi-Fi radio will stay awake when the Phone goes to sleep.
Java
5
star
47

onkyo-eiscp-dotnet

Control Onkyo A/V receivers over the network; in C#, or on the command line. C# port of onkyo-eiscp for Python.
C#
4
star
48

python-smartinspect

A SmartInspect client library for Python (http://www.gurock.com/products/smartinspect/).
Python
4
star
49

ripple-federation-python

ripple/federation-php for Python.
Python
4
star
50

keepscore-android

Keep track of player scores during a card game.
Java
4
star
51

ripple-id

Webservice to identify ripple addresses
Python
4
star
52

ituneslp-tools

Tools to work with iTunes LP / iTunes Extras projects.
JavaScript
4
star
53

SynologyDownloadAssistant

Download directly to your synology diskstation
JavaScript
3
star
54

fretsonfire

Python
3
star
55

stgit

3
star
56

my-logcheck-db

My personal collection of custom logcheck rules, and a small script to apply them.
Python
3
star
57

reposync

Automate mirroring repositories, for example to github.
Python
3
star
58

php-languid

A statistical language guesser in PHP. Port of Maciej Ceglowski's Language::Guess.
PHP
3
star
59

corporeal

Clean, simple Windows Password Manager
Pascal
3
star
60

django-filebrowser

Fork of django-filebrowser that does not require django-grappelli
ActionScript
3
star
61

babel

Git import of python-babel
Python
3
star
62

jinja2utils

My personal collection of Jinja2 utilities.
Python
2
star
63

wsconfig

A tiny utility to automatize setting up a new workstation; linking config files and installing packages.
Python
2
star
64

protobuf

Google Protocol Buffers
C++
2
star
65

consul2vulcan

Go
2
star
66

islamic-patterns

TypeScript
2
star
67

track0

A web spider that makes sense (to me)
Python
2
star
68

gandi-python

Gandi CLI client.
Python
2
star
69

pyparsing

Another git import of pyparsing that won't be kept up to date.
Python
2
star
70

feedparser

Tracks feedparser SVN repository, plus some patches of mine.
Python
2
star
71

wormtail

Pascal
2
star
72

vandelay

A build tool.
Python
2
star
73

django-xappy

Bridges the Xappy Xapian interface with Django.
Python
2
star
74

dvd-vr

Git import. Allow [label] to fallback to timestamp.
C
1
star
75

qdump

Very basic pastebin, Rails test app.
Ruby
1
star
76

import-all-ppa-keys

Copy of http://dev.firefly-it.de/repositories/show/lki
1
star
77

remember

remember, remember...
JavaScript
1
star
78

metadatad

Python
1
star
79

winutils

Stuff I use on Windows.
1
star
80

docker-deploy

Very much hacked together, and a work in progress for now.
Python
1
star
81

gajim-messaging-menu

Integrates Gajim with the Ubuntu Messaging Menu
Python
1
star
82

genericapi

Python
1
star
83

whatisripple.info

One-page explanation of the Ripple payment network, with images.
HTML
1
star
84

yyafl

Clone of git://git.stackfoundry.com/yyafl.git
Python
1
star
85

moneymoney-truelayer

TrueLayer extension for MoneyMoney.app
Lua
1
star
86

gwmap

Mapping Guild Wars with Google Maps.
JavaScript
1
star
87

descarty

A self-hostable Web History.
Python
1
star
88

textgrid-ui

TypeScript
1
star
89

jix

Port of the py.test fixture system to JavaScript
JavaScript
1
star
90

confcollect

Configuration loader for 12factor Python apps, framework-agnostic.
Python
1
star
91

rippletxt

Python parser for ripple.txt
Python
1
star
92

py-snaptests

Python
1
star
93

worldofphoto-i18n

A World of Photo i18n files
Shell
1
star
94

mp3diags

SVN import of Mp3Diags trunk. Does not contain the full history, since /trunk did not always exist.
C++
1
star
95

localtodo

.gitignore local todo files, but sync them through Dropbox.
Python
1
star
96

react-navigation-views

Import of the npm package by the same name, which itself is an extract of the code from React-Native
JavaScript
1
star
97

hibiscus-cvsimport

There is a real git mirror now, see willuhn/hibiscus // git cvsimport for Hibiscus Jameica plugin from www.willuhn.de; to build, you still need a Jameica CVS checkout (see also http://blog.elsdoerfer.name/2011/07/14/building-hibiscus/).
Java
1
star