Code Monkey home page Code Monkey logo

backpack's Introduction

Backpack

Backs up your directories periodically with special handling like snapshoting sqlite file.

When running self-hosting applications, backup is important and we often find different application has different backing up strategies. Simply copying stuff may not be good for applications using database files (e.g. sqlite). Backpack offers a way to specify different rules to snapshot different applications using directory rule and regex-based file rules, and then it uses librclone to backup your files to storage platforms that you wish to backup your files.

Version

v0.1

How to use?

Run directly

Run the binary directly with the following command line arguments:

-config string
    config file path (required)
-try-first
    try backup before running cron
-try-only
    try backup only without starting cron
-version
    show version

For example ./backpack -config config.json -try-first. The config file is a JSON file structured as the following format:

{
    // Config version (optional)
    "version": "0.1",
    // Backup rules
    "backups": [
        {
            // List directories to backup with their own rules
            "directories": [
                {
                    // Directory path
                    "path": "/data/run_files",
                    // Rules for file
                    "file_rules": [
                        {
                            // Regular expression for all files ending in `sqlite3`
                            "regex": ".*sqlite3",
                            // Snapshots these files using `sqlite3 .backup`
                            "command": "sqlite"
                        },
                        {
                            // The regular expression matches relative path in directory path
                            // The file rules are matched in order, the first matched rule
                            // will be executed
                            "regex": "files/\.unwanted/.*",
                            // Ignore these files
                            "command": "ignore"
                        }
                        // The rest of the files will be copied
                    ]
                }
                {
                    "path": "/data/photos"
                    // If no file rules, all directory will be copied,
                    // which is equivalent to:
                    // "file_rules": [
                    //     {
                    //         "regex": ".*",
                    //         "command": "copy"
                    //     }
                    // ]
                }
            ],
            // Rclone remote name in Rclone configuration (the name in [])
            "rclone_remote": "default",
            // Remote path (e.g. bucket name)
            "remote_path": "my_bucket/prefix",
            // The backup schedule
            "schedule": {
                // There are two options to schedule
                // 1. Specifying time HH:MM for every day
                "daily": [
                    "01:00",
                    "12:00",
                    "22:00" // 10:00pm
                ],
                // 2. Specify an interval which can be string like "30m", "1h", "300s", etc.
                "every": "30m" // backup every 30 minutes
            }
        }
        // More backup rules can be specified
    ]
}

Note that comments are not supported in JSON file. They are used to explain the fields here.

The program can be exited using Ctrl-C. If you need to backup sqlite files, please make sure sqlite3 command line is in your PATH.

In Docker

The backpack container can be used to backing up files from other container by sharing their volume path. For example, if you want to back up your vaultwarden password manager's vault files, you can use the following Docker compose file:

version: '3'
services:
  vaultwarden:
    image: 'vaultwarden/server:latest'
    restart: unless-stopped
    volumes:
      - ${HOME}/vaultwarden:/data

  backpack:
    image: 'easyselfhost/backpack:latest'
    restart: unless-stopeed
    volumes:
      # Backpack config file
      - ${HOME}/backpack/config.json:/config/config.json
      # Rclone config file
      - ${HOME}/backpack/rclone.conf:/config/rclone.conf
      - ${HOME}/vaultwarden:/data/vaultwarden

backpack's People

Contributors

easyselfhost avatar

Stargazers

 avatar popy32 avatar  avatar

Watchers

 avatar  avatar

Forkers

msgpo

backpack's Issues

Implement retries for each scheduled workflow

Failures in backup workflow should be retriable. For example:

  • Backing up sqlite databases when they are locked by the application
  • Temporal network failures uploading files

Retries can be implemented in either workflow level or action level (copying file, uploading directories).

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.