Giter VIP home page Giter VIP logo

tarsnap-cron's Introduction

tarsnap-cron

Cron scripts (bash/shell) for tarsnap backup, including scheduled deletion of old backups.

Description

tarsnap is a very useful backup service, with lots of features, which I won't go into here. It allows separate roles, so you could have servers that cannot delete their own backups, even if they're hacked.

These scripts attempt to make it easier for scheduled backups, with scheduled deletion of old backups. If you want to keep X daily backups, Y weekly backups and Z monthly backups, you can.

Archiving and pruning can be run on different systems. The default weekly backups are on Mondays, and monthly backups are on the first.

This is based on work by Tim Bishop.

Some Linux distros are using systemd instead of cron. See the systemd folder for some relevant timers and documentation, contributed by @rphillips.

Changes from the original

I'm writing and testing this on Linux systems. It may work on FreeBSD, or not. You can try it, or just try Bishop's code.

Note: I modified the format of the archive names.

  • an example from Bishop's script - 20140201-010100-monthly-/var/www
  • an example from my script - hostname-www-2014-02-01-0101-monthly

I changed it to incorporate backups from a previous system of my design. The systems to prune old backups are incompatible, so if you switch between this script and his, old backups will stick around longer than they should. It would probably take manual cleanup to fix.

I think this version is more extendible. Instead of reinventing cron, it simply uses a customized crontab. Hourly and yearly backups wouldn't be hard to implement, if there's any demand.

tarsnap-cron's People

Contributors

berenddeboer avatar crash avatar pronoiac avatar stevesbrain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tarsnap-cron's Issues

Add notes on pruning frequencies

Someone just asked about suggested pruning frequencies, and I threw out suggestions:

  • right after running the backup. Tack "&& /usr/local/bin/tarsnap-prune.sh" onto the end of the lines that run the backup.
  • run it manually, whenever you have the inclination; weekly or monthly. You can sanity-check the results if you haven't run it before or if you're paranoid.

Archiving and pruning on different systems

It works. I think it takes a tarsnap --fsck to resync the caches, perhaps on both archiving and pruning servers? Note to self: figure this out and document it when you have spare time again.

tarsnap-prune.sh debug options

The original debug option was for developer use, on a different system. For others to use it, it's probably better and clearer to add an argument for a dry-run, which regenerates the archive list. Or perhaps, add an option if you don't want to regenerate the archive list.

Exclude By Pattern Option

Would be great to be able to specify patterns to exclude from backups. Just like how tarsnap exclude patterns are taken care of, but applied to every backup defined in BACKUP_ARRAY.

If I find time I may fork and submit a pull request.

Run shellcheck on this

I don't think I was aware of shellcheck the last time I worked on this! Checking for style and possible bugs - say, quoting - would be good.

Systemd refuses to enable weekly + daily archives

Systemd current version refuses to enable the weekly and daily archive timers. This is caused by a lack of absolute path to the "test" utility, as indicated by journalctl -xe:

May 19 02:14:48 SERVER systemd[1]: [/etc/systemd/system/tarsnap-archive-daily.service:6] Executable path is not absolute, ignoring: test 4 -ne 1 && test 19 -ne 01 && /usr/local/bin/tarsnap-archive.sh daily
May 19 02:14:48 SERVER systemd[1]: tarsnap-archive-daily.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

This is fixed by PR #7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.