Backing up www directory once a day and the DB dump hourly #511

Closed
opened 2022-03-17 21:48:08 +00:00 by gerdneuman · 3 comments
Contributor

I want ot backup /var/www/ once a day (at night) but the mysql DB on the same server every hour to borgbase. So after reading https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/ it seems like I have to create two almost identical config files. Fine. Still, I do not see how this would work and if would not rather have (also) to run borgmatic from cron given my use case.

Would I need two distinct lines in the crontab (https://projects.torsion.org/borgmatic-collective/borgmatic/src/branch/master/sample/cron/borgmatic) with e.g.

# once a day
0 3 * * * root PATH=$PATH:/usr/bin:/usr/local/bin /root/.local/bin/borgmatic --verbosity -1 --syslog-verbosity 1 --config /etc/borgmatic.d/www.yaml

# every hour
0 * * * * root PATH=$PATH:/usr/bin:/usr/local/bin /root/.local/bin/borgmatic --verbosity -1 --syslog-verbosity 1 --config /etc/borgmatic.d/mysql-dump.yaml

The docs only explain the retention but I fail to see how this would work without having different execution times for borgmatic with cron. Or can I achieve the same just with having two different config files? I am puzzled 🙃

I want ot backup `/var/www/` once a day (at night) but the mysql DB on the same server every hour to borgbase. So after reading https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/ it seems like I have to create two almost identical config files. Fine. Still, I do not see how this would work and if would not rather have (also) to run `borgmatic` from cron given my use case. Would I need two distinct lines in the crontab (https://projects.torsion.org/borgmatic-collective/borgmatic/src/branch/master/sample/cron/borgmatic) with e.g. ```sh # once a day 0 3 * * * root PATH=$PATH:/usr/bin:/usr/local/bin /root/.local/bin/borgmatic --verbosity -1 --syslog-verbosity 1 --config /etc/borgmatic.d/www.yaml # every hour 0 * * * * root PATH=$PATH:/usr/bin:/usr/local/bin /root/.local/bin/borgmatic --verbosity -1 --syslog-verbosity 1 --config /etc/borgmatic.d/mysql-dump.yaml ``` The docs only explain the retention but I fail to see how this would work without having different execution times for borgmatic with cron. Or can I achieve the same just with having two different config files? I am puzzled 🙃
Owner

Would I need two distinct lines in the crontab

That's correct. borgmatic doesn't handle scheduling itself, so if you have scheduling needs, you'll need to use an external tool like cron or systemd. And if you have two distinct scheduling needs, then you'll need two separate entries in cron (or systemd) as per your example. And that does mean two separate borgmatic configurations.

Does that answer your questions, or did I miss something?

> Would I need two distinct lines in the crontab That's correct. borgmatic doesn't handle scheduling itself, so if you have scheduling needs, you'll need to use an external tool like cron or systemd. And if you have *two* distinct scheduling needs, then you'll need two separate entries in cron (or systemd) as per your example. And that does mean two separate borgmatic configurations. Does that answer your questions, or did I miss something?
witten added the
question / support
label 2022-03-17 21:56:17 +00:00
Author
Contributor

I see. Thanks for clarifying. (Maybe the need for calling differently via cron could be mentioned in the docs though.)

I see. Thanks for clarifying. (Maybe the need for calling differently via cron could be mentioned in the docs though.)
Owner

it seems like I have to create two almost identical config files

This is no longer the case! As of borgmatic 1.6.0, you can easily share common configuration among separate borgmatic configuration files. See the documentation on include merging for details.

> it seems like I have to create two almost identical config files This is no longer the case! As of borgmatic 1.6.0, you can easily share common configuration among separate borgmatic configuration files. See [the documentation on include merging](https://torsion.org/borgmatic/docs/how-to/make-per-application-backups/#include-merging) for details.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#511
No description provided.