"borgmatic restore --database all" should error when not actually restoring anything #246

Closed
opened 3 years ago by witten · 2 comments
witten commented 3 years ago
Owner

What I'm trying to do and why

I'm trying to restore databases when I don't actually have any databases configured in borgmatic's configuration. A user might do this accidentally, not realizing that the restore they think is happening (because no error) is actually not restoring anything. Unless they look carefully at the output, they may not realize nothing happened.

Steps to reproduce (if a bug)

# borgmatic restore -c test.yaml -v 2 --archive flux-2019-11-12T16:06:29.673759 --database all

No databases configured in test.yaml. Some database dumps in the archive.

Actual behavior (if a bug)

Ensuring legacy configuration is upgraded
test.borg: Restoring databases from archive flux-2019-11-12T16:06:29.673759
borg extract --debug --list --show-rc /root/tmp/test.borg::flux-2019-11-12T16:06:29.673759
using builtin fallback logging configuration
35 self tests completed in 0.07 seconds
Verified integrity of /root/tmp/test.borg/index.699
TAM-verified manifest
security: read previous location '/root/tmp/test.borg'
security: read manifest timestamp '2019-11-13T00:06:29.827230'
security: determined newest manifest timestamp as 2019-11-13T00:06:29.827230
security: repository checks ok, allowing access
root/tmp
root/tmp/log
root/tmp/test.yaml
root/.borgmatic
root/.borgmatic/postgresql_databases
root/.borgmatic/postgresql_databases/database.example.org
root/.borgmatic/postgresql_databases/database.example.org/users
root/.borgmatic/postgresql_databases/localhost
root/.borgmatic/postgresql_databases/localhost/test
root/.borgmatic/mysql_databases
root/.borgmatic/mysql_databases/172.17.0.2
root/.borgmatic/mysql_databases/172.17.0.2/all
terminating with success status, rc 0

summary:
test.yaml: Successfully ran configuration file

Expected behavior (if a bug)

Error!

Other notes / implementation ideas

Would also be good to check what happens when databases are configured, but none are found in the archive.

Environment

borgmatic version: 1.4.10.dev0

borgmatic installation method: pip install --editable

Borg version: 1.1.10

Python version: 3.7.4

Database version (if applicable): PostgreSQL 11.5, MySQL Ver 15.1 Distrib 10.4.8-MariaDB

operating system and version: Manjaro stable

#### What I'm trying to do and why I'm trying to restore databases when I don't actually have any databases configured in borgmatic's configuration. A user might do this accidentally, not realizing that the restore they think is happening (because no error) is actually not restoring anything. Unless they look carefully at the output, they may not realize nothing happened. #### Steps to reproduce (if a bug) ``` # borgmatic restore -c test.yaml -v 2 --archive flux-2019-11-12T16:06:29.673759 --database all ``` No databases configured in `test.yaml`. Some database dumps in the archive. #### Actual behavior (if a bug) ``` Ensuring legacy configuration is upgraded test.borg: Restoring databases from archive flux-2019-11-12T16:06:29.673759 borg extract --debug --list --show-rc /root/tmp/test.borg::flux-2019-11-12T16:06:29.673759 using builtin fallback logging configuration 35 self tests completed in 0.07 seconds Verified integrity of /root/tmp/test.borg/index.699 TAM-verified manifest security: read previous location '/root/tmp/test.borg' security: read manifest timestamp '2019-11-13T00:06:29.827230' security: determined newest manifest timestamp as 2019-11-13T00:06:29.827230 security: repository checks ok, allowing access root/tmp root/tmp/log root/tmp/test.yaml root/.borgmatic root/.borgmatic/postgresql_databases root/.borgmatic/postgresql_databases/database.example.org root/.borgmatic/postgresql_databases/database.example.org/users root/.borgmatic/postgresql_databases/localhost root/.borgmatic/postgresql_databases/localhost/test root/.borgmatic/mysql_databases root/.borgmatic/mysql_databases/172.17.0.2 root/.borgmatic/mysql_databases/172.17.0.2/all terminating with success status, rc 0 summary: test.yaml: Successfully ran configuration file ``` #### Expected behavior (if a bug) Error! #### Other notes / implementation ideas Would also be good to check what happens when databases are configured, but none are found in the archive. #### Environment **borgmatic version:** 1.4.10.dev0 **borgmatic installation method:** `pip install --editable` **Borg version:** 1.1.10 **Python version:** 3.7.4 **Database version (if applicable):** PostgreSQL 11.5, MySQL Ver 15.1 Distrib 10.4.8-MariaDB **operating system and version:** Manjaro stable
witten added the
bug
label 3 years ago
Poster
Owner

Potential data loss: This is a particularly nasty bug. What happened is that when no databases are configured, no dump patterns get passed to borg extract, which means borg extracts all files in the archive instead of just database dumps, which means it could extract over your actual non-database files! Super not good. I have a fix in hand, and will release it shortly.

**Potential data loss:** This is a particularly nasty bug. What happened is that when no databases are configured, no dump patterns get passed to `borg extract`, which means borg extracts *all* files in the archive instead of just database dumps, which means it could extract *over* your actual non-database files! Super not good. I have a fix in hand, and will release it shortly.
witten added the
data loss
label 3 years ago
Poster
Owner

Fix released in borg 1.4.10. Upgrading is highly recommended!

Fix released in borg 1.4.10. Upgrading is highly recommended!
witten closed this issue 3 years ago
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.