Αrchive: Proxmox Backups to Local USB Devices - VincentSaelzler/HomeLab GitHub Wiki
Archive Notice
This page is just a general guide, and doesn't directly relate to the source files of the project.
Backups to Local USB Devices
Basically, to big external USB HDDs.
Overview
- Start with a wiped hard drive.
- Add a partition table and file system.
- Mount the file system.
- Create a PVE storage entry to point to the file system.
- Pitfalls and Troubleshooting.
Find the Wiped Hard Drive
It shouldn't be mounted anywhere, and shouldn't have any sub-entries (partitions). In this example, it's a 4 TB external hard drive, sdb
.
root@pve1:~# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 136.8G 0 disk
├─sda1 8:1 0 1007K 0 part
├─sda2 8:2 0 512M 0 part /boot/efi
└─sda3 8:3 0 136.2G 0 part
├─pve-root 253:0 0 34G 0 lvm /
├─pve-swap 253:1 0 7G 0 lvm [SWAP]
├─pve-data_tmeta 253:2 0 1G 0 lvm
│ └─pve-data 253:4 0 77.2G 0 lvm
└─pve-data_tdata 253:3 0 77.2G 0 lvm
└─pve-data 253:4 0 77.2G 0 lvm
sdb 8:16 0 3.7T 0 disk
Partition Table and File System
Use fdisk
to create.
# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
The size of this disk is 3.7 TiB (4000787029504 bytes). DOS partition table format can not be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).
Created a new DOS disklabel with disk identifier 0xa3f7f1b7.
Command (m for help): g
Created a new GPT disklabel (GUID: 5794B3D2-112B-4459-BEC6-F614CE19B3DF).
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-7814037133, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-7814037133, default 7814037133):
Created a new partition 1 of type 'Linux filesystem' and of size 3.7 TiB.
Command (m for help): p
Disk /dev/sdb: 3.7 TiB, 4000787029504 bytes, 7814037167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: 5794B3D2-112B-4459-BEC6-F614CE19B3DF
Device Start End Sectors Size Type
/dev/sdb1 2048 7814037133 7814035086 3.7T Linux filesystem
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Use lsblk
to make sure it worked as expected.
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
[sda stuff]
sdb 8:16 0 3.7T 0 disk
└─sdb1 8:17 0 3.7T 0 part
Mount the File System
# mkdir /media/big-usb
# mount /dev/sdc1 /media/big-usb/
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
[sda stuff]
sdb 8:16 0 3.7T 0 disk
└─sdb1 8:17 0 3.7T 0 part /media/big-usb
Create the PVE Storage Entry
This example is configured to store a maximum of 7 backup images for each VM. Add the following entry to the existing ones. Do not delete the other entries in the storage.cfg
file!
# nano /etc/pve/storage.cfg
[other entires - KEEP]
dir: big-usb-backup
path /media/big-usb/
content backup
maxfiles 7
shared 0
Pitfalls and Troubleshooting
This setup isn't a "once-and-done" type thing. Some steps need to be manually re-done each time. The negative impacts of each one are detailed here.
Forgetting to Mount the USB Device
The result here is that the backups will be saved to the local hard drive. The one that the OS is installed on.
If the backup files are small this could go unnoticed. In case the OS boot drive were to fail, all the backups would be lost.
If they were larger, I assume a "no free space error" would happen.
Forgetting to Create the Mount Directory
Not creating /media/big-usb
has the exact same effect as the section above.
That's because PVE auto creates the directory (if it doesn't exist) once the dir: big-usb-backup
entry is added to storage.cfg
.
The net effect is, once again, that files are saved to the local OS hard drive.