mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-01 08:10:39 +00:00
docs
This commit is contained in:
49
docs/markdown/location/cron.md
Normal file
49
docs/markdown/location/cron.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Cron
|
||||
|
||||
Often it is usefull to trigger backups autmatically. For this we can specify a `cron` attribute to each location.
|
||||
|
||||
> Available since version 0.18
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
my-location:
|
||||
from: /data
|
||||
to: my-backend
|
||||
cron: '0 3 * * 0' # Every Sunday at 3:00
|
||||
```
|
||||
|
||||
Here is a awesome website with [some examples](https://crontab.guru/examples.html) and an [explorer](https://crontab.guru/)
|
||||
|
||||
## Installing the cron
|
||||
|
||||
**This has to be done only once, regadless of now many cros you have in your config file.**
|
||||
|
||||
To actually enable cron jobs you need something to call `autorestic cron` on a timed shedule.
|
||||
Note that the shedule has nothing to do with the `cron` attribute in each location.
|
||||
My advise would be to trigger the command every 5min, but if you have a cronjob that runs only once a week, it's probably enough to shedule it once a day.
|
||||
|
||||
### Crontab
|
||||
|
||||
Here is an example using crontab, but systemd would do too.
|
||||
|
||||
First, open your crontab in edit mode
|
||||
|
||||
```bash
|
||||
crontab -e
|
||||
```
|
||||
|
||||
Then paste this at the bottom of the file and save it. Note that in this specific example the `.autorestic.yml` is located in `/srv/`. You need to modify that part of course to fit your config file.
|
||||
|
||||
```bash
|
||||
# This is required, as it otherwise cannot find restic as a command.
|
||||
PATH="/usr/local/bin:/usr/bin:/bin"
|
||||
|
||||
# Example running every 5 minutes
|
||||
*/5 * * * * autorestic -c /srv/.autorestic.yml --ci cron
|
||||
```
|
||||
|
||||
> The `--ci` option is not required, but recommended
|
||||
|
||||
Now you can add as many `cron` attributes as you wish in the config file ⏱
|
||||
|
||||
> :ToCPrevNext
|
58
docs/markdown/location/docker.md
Normal file
58
docs/markdown/location/docker.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Docker
|
||||
|
||||
autorestic supports docker volumes directly, without needing them to be mounted to the host filesystem.
|
||||
|
||||
> Available since version 0.13
|
||||
|
||||
Let see an example.
|
||||
|
||||
```yaml | docker-compose.yml
|
||||
version: '3.7'
|
||||
|
||||
volumes:
|
||||
data:
|
||||
name: my-data
|
||||
|
||||
services:
|
||||
api:
|
||||
image: alpine
|
||||
volumes:
|
||||
- data:/foo/bar
|
||||
```
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
hello:
|
||||
from: 'volume:my-data'
|
||||
to:
|
||||
- remote
|
||||
options:
|
||||
forget:
|
||||
keep-last: 14 # Useful for limitations explained belowd
|
||||
|
||||
backends:
|
||||
remote: ...
|
||||
```
|
||||
|
||||
Now you can backup and restore as always.
|
||||
|
||||
```bash
|
||||
autorestic -l hello backup
|
||||
```
|
||||
|
||||
```bash
|
||||
autorestic -l hello restore
|
||||
```
|
||||
|
||||
If the volume does not exist on restore, autorestic will create it for you and then fill it with the data.
|
||||
|
||||
## Limitations
|
||||
|
||||
Unfortunately there are some limitations when backing up directly from a docker volume without mounting the volume to the host:
|
||||
|
||||
1. Incremental updates are not possible right now due to how the current docker mounting works. This means that it will take significantely more space.
|
||||
2. Exclude patterns and files also do not work as restic only sees a compressed tarball as source and not the actual data.
|
||||
|
||||
If you are curious or have ideas how to improve this, please [read more here](https://github.com/cupcakearmy/autorestic/issues/4#issuecomment-568771951). Any help is welcomed 🙂
|
||||
|
||||
> :ToCPrevNext
|
20
docs/markdown/location/exclude.md
Normal file
20
docs/markdown/location/exclude.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Excluding files
|
||||
|
||||
If you want to exclude certain files or folders it done easily by specifiyng the right flags in the location you desire to filter.
|
||||
|
||||
The flags are taken straight from the [restic cli exclude rules](https://restic.readthedocs.io/en/latest/040_backup.html#excluding-files) so you can use any flag used there.
|
||||
|
||||
```yaml
|
||||
locations:
|
||||
my-location:
|
||||
from: /data
|
||||
to: my-backend
|
||||
options:
|
||||
backup:
|
||||
exclude:
|
||||
- '*.nope'
|
||||
- '*.abc'
|
||||
exclude-file: .gitignore
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
25
docs/markdown/location/forget.md
Normal file
25
docs/markdown/location/forget.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# Forget/Prune Policies
|
||||
|
||||
Autorestic supports declaring snapshot policies for location to avoid keeping old snapshot around if you don't need them.
|
||||
|
||||
This is based on [Restic's snapshots policies](https://restic.readthedocs.io/en/latest/060_forget.html#removing-snapshots-according-to-a-policy), and can be enabled for each location as shown below:
|
||||
|
||||
> **Note** This is a full example, of course you also can specify only one of them
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
etc:
|
||||
from: /etc
|
||||
to: local
|
||||
options:
|
||||
forget:
|
||||
keep-last: 5 # always keep at least 5 snapshots
|
||||
keep-hourly: 3 # keep 3 last hourly shapshots
|
||||
keep-daily: 4 # keep 4 last daily shapshots
|
||||
keep-weekly: 1 # keep 1 last weekly shapshots
|
||||
keep-monthly: 12 # keep 12 last monthly shapshots
|
||||
keep-yearly: 7 # keep 7 last yearly shapshots
|
||||
keep-within: '2w' # keep snapshots from the last 2 weeks
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
18
docs/markdown/location/hooks.md
Normal file
18
docs/markdown/location/hooks.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Hooks
|
||||
|
||||
Sometimes you might want to stop an app/db before backing up data and start the service again after the backup has completed. This is what the hooks are made for. Simply add them to your location config. You can have as many commands as you wish.
|
||||
|
||||
```yml | .autorestic.yml
|
||||
locations:
|
||||
my-location:
|
||||
from: /data
|
||||
to: my-backend
|
||||
hooks:
|
||||
before:
|
||||
- echo "Hello"
|
||||
- echo "Human"
|
||||
after:
|
||||
- echo "kthxbye"
|
||||
```
|
||||
|
||||
> :ToCPrevNext
|
27
docs/markdown/location/overview.md
Normal file
27
docs/markdown/location/overview.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# 🗂 Locations
|
||||
|
||||
Locations can be seen as the input to the backup process. Generally this is simply a folder.
|
||||
The paths can be relative from the config file. A location can have multiple backends, so that the data is secured across multiple servers.
|
||||
|
||||
```yaml | .autorestic.yml
|
||||
locations:
|
||||
my-location-name:
|
||||
from: path/to/backup
|
||||
to:
|
||||
- name-of-backend
|
||||
- also-backup-to-this-backend
|
||||
```
|
||||
|
||||
## `from`
|
||||
|
||||
This is the source of the location.
|
||||
|
||||
#### How are paths resolved?
|
||||
|
||||
Paths can be absolute or relative. If relative they are resolved relative to the location of the config file. Tilde `~` paths are also supported for home folder resolution.
|
||||
|
||||
## `to`
|
||||
|
||||
This is einther a single backend or an array of backends. The backends have to be configured in the same config file.
|
||||
|
||||
> :ToCPrevNext
|
Reference in New Issue
Block a user