Restore single files from host backup (pxar) on cli non-interactive

l_fish

Active Member
Aug 28, 2018
12
1
43
44
Hi!

I've set up a Proxmox backup server instance (pbs1) for testing and created a host backup from another maschine (server1) with the following command:

server1# proxmox-backup-client backup root.pxar:/ --repository user1@pbs@pbs1:datastore1

This works fine, snapshots are created as expected. Now I want to restore single files from a snapshot. I know, that I could use the GUI to download single files or an interactive restore with proxmox-backup-client catalog shell ... but I need a non-interactive (scriptable) way to restore specific files. Something like:

proxmox-backup-client restore host/server1/2020-09-01T08:49:06Z root.pxar FILE(S)_TO_RESTORE /target/path/

where FILE(S)_TO_RESTORE would be a pattern / glob of the files to restore.

Maybe I missed something. Is there any solution for this?


Best regards,
Lars
 
Hi Lars,

Currently, the best way I can think of to achieve what you described (i.e. a scriptable way to restore single files from a pxar archive), would be to use proxmox-backup-client mount (see Mounting of archives via fuse).
Note: the command currently has a bug, which has rendered it unusable. However, I have submitted a patch that fixes it, so I will report back as soon as it's been integrated!
In the meantime, if you would prefer something closer to what you described, you can also submit a feature request over at bugzilla.
 
Hi dylanw,

I wasn't aware of the mount command, thank you for that hint! It will be interesting to see how performance is on very large backups. I will try it as soon as it is usable again.

A single files restore command would be a bit more handy than mounting and IMHO it is a functionality one would expect from a backup solution especially since proxmox-backup-client supports it already interactively via the cataloge shell command. So therefore i opened a feature request: https://bugzilla.proxmox.com/show_bug.cgi?id=2996
 
Hi Lars,

Just writing to let you know that the mount option, mentioned in my previous message is working again.
 
Hi dylanw,

thats good news, thank you! I can confirm: mount option is working now (with proxmox-backup-client 0.8.16) and it is fast enough for my use cases. So I will be using that now.
 
  • Like
Reactions: dylanw
Hi Lars,

Currently, the best way I can think of to achieve what you described (i.e. a scriptable way to restore single files from a pxar archive), would be to use proxmox-backup-client mount (see Mounting of archives via fuse).
Note: the command currently has a bug, which has rendered it unusable. However, I have submitted a patch that fixes it, so I will report back as soon as it's been integrated!
In the meantime, if you would prefer something closer to what you described, you can also submit a feature request over at bugzilla.

That link to the docs for the fuse mounting is not working - have you got a better one?
 
aha - thanks

Code:
proxmox-backup-client mount host/backup-client/2020-01-29T11:29:22Z root.pxar /mnt/mountpoint

Could you expand the description of this command? It is not clear to me if "host" and "backup-client" are part of the snapshot name or needs the host and the "backup-client" in the snapshot reference.
 
You can find more information on that in the terminology section of the docs [1]. Here "host" is the backup type, "backup-client" is the hostname of the system, and the time relates to the backup time. This is how snapshots are referenced in PBS.

[1] https://pbs.proxmox.com/docs/terminology.html#backup-snapshot
 
Ok, thanks that is very useful, I am getting failure when I try it, but I'll post in a new thread...
 
I suppose scriptable restore is not implemented yet. At least restore command does not allow for patterns etc.

I came up with the following Expect script which should be adaptable with minor modifications to this purpose until this feature is available in the client itself. Run like this: restore.exp <snapshot> <archive.pxar> <file pattern> <restore directory path>

Code:
#!/usr/bin/expect -f

set force_conservative 1;
if {$force_conservative} {
    set send_slow {1 .1}
    proc send {ignore arg} {
        sleep .1
        exp_send -s -- $arg
    }
}

global OPTS;
set OPTS(snap)  [lindex $argv 0];
set OPTS(arch)  [lindex $argv 1];
set OPTS(files) [lindex $argv 2];
set OPTS(dir)   [lindex $argv 3];
set prompt {pxar:\/ > };
set timeout -1;

spawn proxmox-backup-client shell $OPTS(snap) $OPTS(arch)
match_max 100000
expect -exact "Starting interactive shell\r"
expect -re $prompt
send -- "find $OPTS(files) --select\r"
expect -re $prompt
send -- "restore-selected $OPTS(dir)\r"
expect -re $prompt
send -- "exit\r"
expect eof
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!