Difference between revisions of "PVE External Drive Backups"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 18: Line 18:


= Putting this to use =
= Putting this to use =
<span style="color: rgb(51, 102, 255);" >Note:</span> This involves setting up the drives in advance...
<span style="color: rgb(51, 102, 255);">Note:</span> This involves setting up the drives in advance...


: You will need to set them up as GPT / EXT4 and give them matching labels.
: You will need to set them up as GPT / EXT4 and give them matching labels.
: Create a new '''Directory''' storage device in '''Datacenter/Storage''' & point it at the symlink in '''/var/run/usbmount/'''
:: (see [[Adding a new drive from the command line]] for a guide...)
:: <span style="color: rgb(186, 55, 42);" >'''WIP:'''</span> More detail to come...
Create a new '''Directory''' storage device in '''Datacenter/Storage''' & point it at the symlink in '''/var/run/usbmount/'''


<span style="color: rgb(255, 0, 0);" >'''CAVEAT:'''</span> You will need to disable this device before removing or swapping drives.
<span style="color: rgb(255, 0, 0);">'''CAVEAT:'''</span> You will need to disable this device before removing or swapping drives.


<s>(Going to the CLI & telling PVE that this storage is a mountpoint might be the correct solution... <code>pvesm set '''External''' -is_mountpoint yes</code>)</s>
<s>(Going to the CLI & telling PVE that this storage is a mountpoint might be the correct solution... <code>pvesm set '''External''' -is_mountpoint yes</code>)</s>


<span style="color: rgb(255, 0, 0);" >AAAnnnddd...</span> PVE '''STILL''' seems to do weird shit... If the directory is enabled while the drive is not connected, PVE will create the structure it expects to see on that drive as a folder where the symlink is supposed to be. Needless to say, this is a bit of a problem. When you plug the drive back in, USBmount cannot create the symlink to access the drive.
'''<span style="color: rgb(255, 0, 0);" >AAAnnnddd...</span>''' PVE '''STILL''' seems to do weird shit... If the directory is enabled while the drive is not connected, PVE will create the structure it expects to see on that drive as a folder where the symlink is supposed to be. Needless to say, this is a bit of a problem. When you plug the drive back in, USBmount cannot create the symlink to access the drive.


= BTTDB... =
= BTTDB... =
Line 59: Line 61:
* How do I actually ensure it's safe to yank the drive?
* How do I actually ensure it's safe to yank the drive?
** For now... As long as you either disable it in the UI or on the CLI, it's all good. (Doing it in the UI means you have no excuse to fail to see if a backup is in progress too!)
** For now... As long as you either disable it in the UI or on the CLI, it's all good. (Doing it in the UI means you have no excuse to fail to see if a backup is in progress too!)
*** Log into the UI
*** Using the UI
*** go to&nbsp;'''Datacenter / Storage'''
**** go to '''Datacenter / Storage'''
*** select the directory in question ('''External''' in our example here...)
**** select the directory in question ('''External''' in our example here...)
*** Click the '''Edit''' button
**** Click the '''Edit''' button
*** uncheck '''Enable'''
**** uncheck '''Enable'''
*** Click '''OK'''
**** Click '''OK'''
*** Now you can unplug the drive safely
**** Now you can unplug the drive safely
*** Using the CLI
**** <code>pvesm set '''External''' --disable 1</code>

Latest revision as of 18:06, 10 April 2023

First, need USB drive handling.

A starting point: USBmount

Taking this a step further

Putting this to use

Note: This involves setting up the drives in advance...

You will need to set them up as GPT / EXT4 and give them matching labels.
(see Adding a new drive from the command line for a guide...)
WIP: More detail to come...

Create a new Directory storage device in Datacenter/Storage & point it at the symlink in /var/run/usbmount/

CAVEAT: You will need to disable this device before removing or swapping drives.

(Going to the CLI & telling PVE that this storage is a mountpoint might be the correct solution... pvesm set External -is_mountpoint yes)

AAAnnnddd... PVE STILL seems to do weird shit... If the directory is enabled while the drive is not connected, PVE will create the structure it expects to see on that drive as a folder where the symlink is supposed to be. Needless to say, this is a bit of a problem. When you plug the drive back in, USBmount cannot create the symlink to access the drive.

BTTDB...

  • pvesm set External --disable 1
  • swap drives
  • pvesm set External --disable 0

Seems to do the job at the CLI.

Just need to wait for the symlink to be created. But, that does happen in a script, so...

  • vi /etc/usbmount/mount.d/01_create_label_symlink
    • Add
      • pvesm set $label --disable 0
    • at the end (before the exit 0 line...). This will enable the drive upon connection.

Just need to figure out how to send the disable & let the user know to swap the drives.

  • vi /etc/usbmount/umount.d/00_remove_model_symlink
    • Add
      • pvesm set External --disable 1
    • at the start

This actually seems to function... sometimes... But only if the timing works out that it disables the directory before PVE notices the drive is missing.

TBD

  • Still need to work on making sure Proxmox knows when it's safe to actually backup to it...
    • (IE: detect the backup drive is present & possibly which one of a set it is...)
    • In fact... As long as the directory is disabled while the drive is unplugged, PVE will simply error out the backup & give a message about it.
      • TASK ERROR: could not activate storage 'External': storage 'External' is disabled
    • Which is just fine...
  • How do I actually ensure it's safe to yank the drive?
    • For now... As long as you either disable it in the UI or on the CLI, it's all good. (Doing it in the UI means you have no excuse to fail to see if a backup is in progress too!)
      • Using the UI
        • go to Datacenter / Storage
        • select the directory in question (External in our example here...)
        • Click the Edit button
        • uncheck Enable
        • Click OK
        • Now you can unplug the drive safely
      • Using the CLI
        • pvesm set External --disable 1