How to migrate existing backups to PBS

proximoxi2

Member
Nov 1, 2019
10
0
21
47
We currently have two debian servers with a zfs pool to which we backups our containers and vm's (via NFS). We now want to migrate to PBS. Replace one of the servers to PBS, migrate the existing backups and then replace the other server.

But how do we migrate existing backups to PBS? I have not found any documentation about this.
 
Since it is on the roadmap since three and a half years I guess I should not expect that it gets implemented soon.
Restoring a few hundred backups does not scale very well, but I think we could extract the archives sequentially and use the proxmox backup client to backup them to pbs.
 
no, for container backups no such tool exists yet. you can always extract the backup (it's a tar file containing the rootfs and the container configs), and then back it up again using proxmox-backup-client like vzdump does (that allows matching the PBS snapshot timestamp to that of the old backup), or you could use pct restore and vzdump and lose the timestamps..
 
vma-to-pbs work well There were only two unexpected downsides. By default vma-to-pbs will use the current timestamp when importing the backup which makes importing the backup kind of useless when i have 10 backups from "now". There is `--backup-time <EPOCH>` , but that should be used in the examples imho. Also it would be nice if `vma-to-pbs --help` could specify what EPOCH is, but it seems to be a unix timestamp in seconds.
If you already have newer backups of the VM you get a
`Error: proxmox_backup_connect failed: command error: backup timestamp is older than last backup.`
But we could work around that by moving some files on the pbs server.

And here is a script you maybe also could add to the wiki because i guess migration from file based backups to pbs is the most common use case for this tool:
```bash
#!/bin/bash
for file in *.vma.zst; do
vmid=$(echo "$file" | grep -oP '(\d+)-\d{4}_\d{2}_\d{2}-\d{2}_\d{2}_\d{2}' | grep -oP '^\d+')
backup_time=$(date -d "$(echo "$file" | grep -oP '\d{4}_\d{2}_\d{2}-\d{2}_\d{2}_\d{2}' | tr '_' ' ')" +"%s")
zstd -d --stdout "$file" | \
PBS_FINGERPRINT='PBS-FINGERPRINT' vma-to-pbs \
--repository 'user@realm!token@server:port:datastore' \
--vmid "$vmid" \
--backup-time "$backup_time" \
--password-file path/to/pbs_password
done
```

And for imported VMs the comment is empty, but this information is there in the `qemu-server.conf` file. It would be nice if the name from there is used as comment.
 

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!