Extracting archives to remote pc #494

Closed
opened 2022-01-31 08:39:24 +00:00 by elhananjair · 14 comments

What I'm trying to do and why

Hello there, I wanted to extract archives to remote pc. I couldn't find in documentation of borgmatic extract. Is it possible to set remote path using --destination flag? Thanks

Steps to reproduce (if a bug)

Not a bug

Actual behavior (if a bug)

Not a bug

Expected behavior (if a bug)

Not a bug

Other notes / implementation ideas

Environment

borgmatic version: [1.5.21]

Use sudo borgmatic --version or sudo pip show borgmatic | grep ^Version

borgmatic installation method: [Fedora package]

Borg version: [1.1.17]

Use sudo borg --version

Python version: [3.10.2]

Use python3 --version

Database version (if applicable): [13.4]

Use psql --version or mysql --version on client and server.

operating system and version: [Fedora Server 35]

#### What I'm trying to do and why Hello there, I wanted to extract archives to remote pc. I couldn't find in documentation of borgmatic extract. Is it possible to set remote path using --destination flag? Thanks #### Steps to reproduce (if a bug) Not a bug #### Actual behavior (if a bug) Not a bug #### Expected behavior (if a bug) Not a bug #### Other notes / implementation ideas #### Environment **borgmatic version:** [1.5.21] Use `sudo borgmatic --version` or `sudo pip show borgmatic | grep ^Version` **borgmatic installation method:** [Fedora package] **Borg version:** [1.1.17] Use `sudo borg --version` **Python version:** [3.10.2] Use `python3 --version` **Database version (if applicable):** [13.4] Use `psql --version` or `mysql --version` on client and server. **operating system and version:** [Fedora Server 35]
witten added the
question / support
label 2022-01-31 19:20:55 +00:00
Owner

Unfortunately, it's not currently possible to use a remote --destination with borgmatic extract. Only local paths will work there.

One work-around could be if you first mounted a remote filesystem so as to appear local, e.g. using NFS or SMB. In that case, you could borgmatic extact --destination directly to that local mount point.

Unfortunately, it's not currently possible to use a remote `--destination` with `borgmatic extract`. Only local paths will work there. One work-around could be if you first mounted a remote filesystem so as to appear local, e.g. using NFS or SMB. In that case, you could `borgmatic extact --destination` directly to that local mount point.
Author

Unfortunately, it's not currently possible to use a remote --destination with borgmatic extract. Only local paths will work there.

One work-around could be if you first mounted a remote filesystem so as to appear local, e.g. using NFS or SMB. In that case, you could borgmatic extact --destination directly to that local mount point.

Ok thank you so much I've done it using sftp. Before closing this issue, I just wanted to be clear about restoring db. does borgmatic restore --archive archivename command works just like

PGPASSWORD="password" psql -h [server] -U [username] -d dbname -f db-sqlbkp.bak

or does it extract the database dump to current directory thanks.

> Unfortunately, it's not currently possible to use a remote `--destination` with `borgmatic extract`. Only local paths will work there. > > One work-around could be if you first mounted a remote filesystem so as to appear local, e.g. using NFS or SMB. In that case, you could `borgmatic extact --destination` directly to that local mount point. Ok thank you so much I've done it using sftp. Before closing this issue, I just wanted to be clear about restoring db. does *borgmatic restore --archive archivename* command works just like > PGPASSWORD="password" psql -h [server] -U [username] -d dbname -f db-sqlbkp.bak or does it extract the database dump to current directory thanks.
Owner

borgmatic restore actually streams the database restore directly from Borg to psql or pg_restore. That way it never needs to take up space in a temporary file.

`borgmatic restore` actually *streams* the database restore directly from Borg to `psql` or `pg_restore`. That way it never needs to take up space in a temporary file.
Author

borgmatic restore actually streams the database restore directly from Borg to psql or pg_restore. That way it never needs to take up space in a temporary file.

ow ok I was almost replaced my current database if that so, but in my case I am storing my backups to remote pc, how can I restore my db to another remote pc then?
am sorry for raising unrelated topic

> `borgmatic restore` actually *streams* the database restore directly from Borg to `psql` or `pg_restore`. That way it never needs to take up space in a temporary file. ow ok I was almost replaced my current database if that so, but in my case I am storing my backups to remote pc, how can I restore my db to another remote pc then? am sorry for raising unrelated topic
Owner

Two options:

  • Configure borgmatic to connect to a remote database host, e.g. in the hostname of the database hook.
  • Or, run borgmatic on the remote PC with the database and configure it to restore from a remote repository, e.g. via SSH.
Two options: * Configure borgmatic to connect to a remote database host, e.g. in the hostname of the database hook. * Or, run borgmatic *on* the remote PC with the database and configure it to restore from a remote repository, e.g. via SSH.
Author

Two options:

  • Configure borgmatic to connect to a remote database host, e.g. in the hostname of the database hook.
  • Or, run borgmatic on the remote PC with the database and configure it to restore from a remote repository, e.g. via SSH.

Thanks for your reply:
for option one: I have already configured hostname: localhost because am backup up my database from my local machine where I have installed borgmatic and borg. I am little bit confused so take look at my structure here and can you please explain to me how can I restore pg db, am sorry for taking your time.

image

> Two options: > * Configure borgmatic to connect to a remote database host, e.g. in the hostname of the database hook. > * Or, run borgmatic *on* the remote PC with the database and configure it to restore from a remote repository, e.g. via SSH. Thanks for your reply: for option one: I have already configured hostname: localhost because am backup up my database from my local machine where I have installed borgmatic and borg. I am little bit confused so take look at my structure here and can you please explain to me how can I restore pg db, am sorry for taking your time. ![image](/attachments/b40c4fd6-cd23-4cb5-94c5-a4630b8eef9d)
Owner

Would it be possible for you to run borgmatic extract and borgmatic restore on S1 with the "localhost" database configuration and a remote Borg repository (P2)? Then it would install your files and database to S1.

Would it be possible for you to run `borgmatic extract` and `borgmatic restore` *on S1* with the "localhost" database configuration and a remote Borg repository (P2)? Then it would install your files and database to S1.
Author

Would it be possible for you to run borgmatic extract and borgmatic restore on S1 with the "localhost" database configuration and a remote Borg repository (P2)? Then it would install your files and database to S1.

That works exactly as I wanted amazing @witten!
I didn't know that I could run borgmatic extract/restore commands on other machines if I have got config.yaml config file. Well what can I say, Thank you so much!
And just little bit as a suggestion I would like such tips to be included on borgmatic docs, it might be useful for someone like me.

> Would it be possible for you to run `borgmatic extract` and `borgmatic restore` *on S1* with the "localhost" database configuration and a remote Borg repository (P2)? Then it would install your files and database to S1. That works exactly as I wanted amazing @witten! I didn't know that I could run borgmatic extract/restore commands on other machines if I have got config.yaml config file. Well what can I say, Thank you so much! And just little bit as a suggestion I would like such tips to be included on borgmatic docs, it might be useful for someone like me.
Owner

Glad to hear that works out for you!

Glad to hear that works out for you!
Contributor

I have a very similar use case (Backup a remote server and extract those files/DBs on a local PC).

@elhananjair / @witten would you mind sharing some details about the borgmatic configuration files?

I guess I would need to copy the borgmatic/config.yaml from the remote server to my local PC - but then remove the location:source_directories lines from it? Because I do not want to backup any files/directories on the local PC, but only do a extract/restore there.

Is that correct?

I have a very similar use case (Backup a remote server and extract those files/DBs on a local PC). @elhananjair / @witten would you mind sharing some details about the borgmatic configuration files? I guess I would need to copy the borgmatic/config.yaml from the remote server to my local PC - but then remove the `location`:`source_directories` lines from it? Because I do not want to backup any files/directories on the local PC, but only do a extract/restore there. Is that correct?
Owner

Yes, that sounds like it should work! Although you wouldn't even have to remove the source_directories if you only ever run an extract/restore from that local PC. source_directories is only used on create.

Yes, that sounds like it should work! Although you wouldn't even have to remove the `source_directories` if you only ever run an `extract`/`restore` from that local PC. `source_directories` is only used on `create`.
Contributor

Seems to work. Indeed I get an error without having source_directories:

/etc/borgmatic/config.yaml: Error parsing configuration file
An error occurred while parsing a configuration file at /etc/borgmatic/config.yaml:
Cannot find required key 'source_directories'. Path: '/location'

Though, I would prefer to not have those in my config.yaml to avoid running accidentically create on the local PC and overriding the backup.

Thanks for maintaining borgmatic :-)

Seems to work. Indeed I get an error without having source_directories: ``` /etc/borgmatic/config.yaml: Error parsing configuration file An error occurred while parsing a configuration file at /etc/borgmatic/config.yaml: Cannot find required key 'source_directories'. Path: '/location' ``` Though, I would prefer to not have those in my `config.yaml` to avoid running accidentically `create` on the local PC and overriding the backup. Thanks for maintaining borgmatic :-)
Owner

Sure thing! source_directories is required.. but its value can be an empty list. See #364 for an example!

Sure thing! `source_directories` is required.. but its value can be an empty list. See #364 for an example!
Contributor

Uh, great, thanks for pointing me to #364. Well, as @elhananjair already said in #494 (comment) the use case of having one machine that does backups and then a totally other machine only used for extracts or checks or local restores might deserve an Howto within the documentation.

(Or I did not find it, though, I even also searched the issuee tracker too)

Please ignore if you disagree :-)

Thanks again.

Uh, great, thanks for pointing me to #364. Well, as @elhananjair already said in https://projects.torsion.org/borgmatic-collective/borgmatic/issues/494#issuecomment-4016 the use case of having one machine that does backups and then a totally other machine only used for extracts or checks or local restores might deserve an Howto within the documentation. (Or I did not find it, though, I even also searched the issuee tracker too) Please ignore if you disagree :-) Thanks again.
Sign in to join this conversation.
No Milestone
No Assignees
3 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#494
No description provided.