Download the PHP package nazar-pc/just-backup-btrfs without Composer
On this page you can find all versions of the php package nazar-pc/just-backup-btrfs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nazar-pc/just-backup-btrfs
More information about nazar-pc/just-backup-btrfs
Files in nazar-pc/just-backup-btrfs
Package just-backup-btrfs
Short Description Script that does just that - creates backups using snapshot of btrfs filesystem. Also it makes rotation of snapshots by removing old ones and keeping as many snapshots as you want.
License MIT
Homepage https://github.com/nazar-pc/just-backup-btrfs
Informations about the package just-backup-btrfs
Just backup btrfs
Script that does just that - creates backups using snapshot of btrfs filesystem. Also it makes rotation of snapshots by removing old ones and keeping as many snapshots as you want.
Why?
I wanted simple thing: store snapshots of several subvolumes in one place and keep specific number of snapshots for each time interval (more recent and less elder snapshots).
I was wondered that no existing solutions fit my needs, so I decided to write it:)
Requirements
- php-cli (version 5.4+)
- php-sqlite3
You can get them both on Ubuntu 15.10-:
Ubuntu 16.04+:
Also enable sqlite3 extension since it may be disabled by default. Ubuntu 15.10-:
Ubuntu 16.04+
Installation
The whole thing is a single file, so first way is just to copy file just-backup-btrfs somewhere.
Alternatively you can install it globally using Composer like this:
COMPOSER_BIN_DIR=/usr/local/bin will instruct Composer to install binary to /usr/local/bin so that you'll be able to call just-backup-btrfs right after installation.
Alternatively you can skip it and add ~/.composer/vendor/bin/ to your PATH.
Removal
If installed manually - just remove file, if installed with Composer - remove it with:
Or without COMPOSER_BIN_DIR=/usr/local/bin if you didn't use it during installation.
Usage
Script expects configuration file to be present at location /etc/just-backup-btrfs.json, example of such file you can find below. Also, if you want to use other path to config file - specify it as argument.
There are few ways to run script.
or mark file as executable and just
or mark as executable and put into /etc/cron.daily to make backups every day.
With custom path to config file:
Output will be like this:
Also you can call it with cron or in some other way:)
What it actually does?
- reads configuration from
/etc/just-backup-btrfs.json - creates
destination_within_partition/history.dbSQLite database if it doesn't exists yet - creates snapshot with date as the name inside
destination_within_partition - creates backups (copies of snapshots inside
destination_within_partition) insidedestination_other_partitionfor the case when source filesystem crashes - store snapshot name, date and how long snapshot should be kept in
destination_within_partition/history.db(anddestination_other_partition/history.db, since backups might have own retention settings) - reads old snapshots stored in
destination_within_partition/history.db(anddestination_other_partition/history.db) and remove them fromhistory.dband from filesystem
Configuration
Configuration options are especially made self-explanatory:
source_mounted_volume- string, absolute path, subvolume to backup/create snapshot ofdestination_within_partition- string, absolute path, where to store snapshots, should be the same partition assource_mounted_volumedestination_other_partition- string, absolute path (ornullif not needed), where to store actual backup, expected to be another BTRFS partitiondate_format- string, date format as for PHP date() functionkeep_snapshots- array with keyshour,day,monthandyear, each key contains number of snapshots that must be kept within corresponding time interval (-1means unlimited)keep_other_snapshots- the same askeep_snapshots, but for backups,keep_snapshotsby defaultoptimize_mounts- allows to avoid constant remounting root during external backups since it might be slow;trueby default, might be disabled if necessaryminimum_delete_count- minimum number of snapshots to remove, is used to decrease fragmentation and thus improve performance,1by defaultminimum_delete_count_other- the same asminimum_delete_count, but for backups,minimum_delete_countby default
Save this config as /etc/just-backup-btrfs.json and customize as you like.
License
MIT, feel free to hack it and share!
All versions of just-backup-btrfs with dependencies
ext-sqlite3 Version *