Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extracting files from a backup archive #104

Open
jsabater opened this issue Sep 7, 2022 · 2 comments
Open

Allow extracting files from a backup archive #104

jsabater opened this issue Sep 7, 2022 · 2 comments

Comments

@jsabater
Copy link

jsabater commented Sep 7, 2022

Dear contributors,

I'd like to kindly request adding the necessary code to be able to extract files from an archive in a remote repository. This, in turn, could be use in combination with other tasks to, say, restore a database, etc.

It would be the equivalent to executing the following commands in the console:

BORG_PASSPHRASE="CHANGEME" \
[email protected]:repo \
borg extract --strip-components 3 ::<archive> var/backups/postgresql/database.bak

The command would be executed in the host, so the file would be extracted in the host where Ansible is connected to. The target directory (e.g. /root/database.bak) should be configurable.

Thanks in advance.

@m3nu
Copy link
Collaborator

m3nu commented Sep 7, 2022

I don't see why you would use Ansible for this and how it's within the scope of this project. Any reason why you can't use Borg directly?

@jsabater
Copy link
Author

jsabater commented Sep 7, 2022

One use case is to extract a copy of the (PostgreSQL | MongoDB | MySQL) production database(s) that was backed up last night and restore it in a test server.

Since they are all inside LinuX Containers and developers don't have access to such containers, I'd like them to connect to a bastion container with Ansible installed and execute a playbook. This playbook would execute a number of tasks, such as:

  1. Extract the database.bak file from a given archive in the remote repository somewhere into the test server.
  2. Use pg_restore (or similar) to restore the dump.
  3. Use psql to execute a number of SQL commands to finetune/adapt the restored data.

There is already a BASH script that does this. I could create an Ansible playbook that just executes such script, but I thought it nice to turn it all into a playbook, as there is already Ansible support for PostgreSQL to dump and restore databases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants