Simple Backup Method to USB drive

dragonslayr

Renowned Member
Mar 5, 2015
53
2
73
Having used proxmox for our own needs, I'm thinking to use it for some small clients.

I need some ideas for simple (very simple) instructions to check the backup and swap usb drives:

Have you guys got a method you tell a secretary or whomever to change backup drives?
 
  • Like
Reactions: DHY and Ivanoz
For my part, i have installed "usbmount"

With it, all usb drive are automatic mounted in /media/usbx

In Proxmox, add a directory to /media/usbx
 
For my part, i have installed "usbmount"

With it, all usb drive are automatic mounted in /media/usbx

In Proxmox, add a directory to /media/usbx

This sounds good. Of course they need to know the backup was successful, so I guess I might point the email to them. (Though I'd like to get a copy)
Then just have them swap the drives after they get the email which would mean the backup had finished...
 
Vzdump is the tool. On GUI it called backup
 
Vzdump is the tool. On GUI it called backup

Yes. I understand that vzdump is a command line tool.

However what did you mean by this bit that I quoted?

important is you must select vzdump on the Storage window

Select vzdump? What are you talking about? How do you "select" vzdump?

Are you referring to the Content type being set to "Backups" to allow for backups to be stored?
 
Correct.
 
For my part, i have installed "usbmount"

With it, all usb drive are automatic mounted in /media/usbx

In Proxmox, add a directory to /media/usbx

The new 4.0 beta no longers seems to work with usbmount, through no fault of it's own. The package is no longer maintained. So I reverted to mounting by drive label.
mount -L backup_drive /mnt/backup_drive
 
Hi,
you must mount your usb drive like here explained



then you can add via GUI a new Storage Datacenter->Storage->Add->Directory

and then use the path where you mount the usbDisk.

important is you must select vzdump on the Storage window.

Hello,
i know this thread is old, but i tried the exact same thing and it worked so thanks for the hint.

Until i rebooted the host. I the now the issue that VE is in emergency mode. And its because of the USB. Its not mounted while boot so thats the Error. If i mount it manual while in the emergency, and then "exit" - i can boot (or rather start) proxmox. I also found that in the emergency, if i type "mount -a" there is a error with the USB thingy, but if i type "mount /dev/sdb1 /media/usb-drive/" its mounting as it should and when i run "mount -a" after that, there is no error at all (guess because its already mounted right).

I guess this is because the process changed over the years? Can someone help me? Much appreciated :)
Im fairly new to debian and shell and stuff so appologies in advance.

Regards, Mark
 
I suggest you NOT mount the backup drive in fstab. What I settled on is mounting by drive label.

Here's what I do to prep a drive and give it a drive label.

######### Prep backup drives Note: this will wipe the drive.
Code:
gdisk /dev/sd?
d
n
defaults a few times
w


# format it to ext4
mkfs -t ext4 -q /dev/sd?1 -L backup_offsite

Now that the disk has a backup label and is formatted, you can mount like this:
# Mount it and make the backup directory
Code:
mount -L backup_offsite /mnt/backup_offsite
mkdir -p /mnt/backup_offsite/dump
Then put in /etc/crontab to mount at boot
Code:
@reboot                 root    mount -L backup_offsite /mnt/backup_offsite
Note: the above command is a tad different than mine as I put this command in a script file that then runs from cron.

Then here's my relevant portion of storage.cfg

Later version of proxmox support is_mountpoint. This will stop proxmox from backing up if the drive is not mounted. Also, I disable proxmox creating the backup directory.
Edit /etc/pve/storage.cfg
Add to the bottom:
Code:
dir: backup_offsite
        path /mnt/backup_offsite
        content backup
        maxfiles 3
        shared 0
        is_mountpoint 1
        mkdir 0
 
  • Like
Reactions: tuneboy
I use this in /etc/fstab:
Code:
LABEL=backup       /mnt/backup     ext4    noauto,x-systemd.automount      0 0

The rest of the setup is similar to @dragonslayr . The advantage is that you can disable the storage in the GUI or from then command line, then unmount to switch drives. Upon re-enabling the storage it will get mounted automatically. I rotate my backups off-site once a month using this method.
 
Oh, and the command the customer runs is: switchdrives

Note, it needs "dialog" installed apt-get install dialog
In that bash script is this:

Code:
#!/bin/bash

getscript() {
  pgrep -lf ".[ /]$1( |\$)"
}


mailto=root
drivename=backup_offsite
drivepath=/mnt/$drivename
directory=dump
mname="Change Offsite Drive"


if (dialog --title "$mname" --yesno "Are you ready to replace the drive?" 10 35)
# message box will have the size 25x6 characters
then

dialog --title "$mname" --infobox "Unmounting Drive, Please wait" 10 35

umount $drivepath>|/tmp/ERRORS$$ 2>&1


    if [ "$?" = "0" ]
        then
            dialog --title "$mname" --msgbox "Drive is unmounted, Please change the drives now. Press Enter when ready to continue" 10 35
        else
            dialog --title "$mname" --msgbox "Unmounting failed -- Press <Enter> to see error log." 10 35
            dialog --title "Error Log" --textbox /tmp/ERRORS$$ 10 62
            dialog --title "$mname" --msgbox "Unmounting failed -- Your two choices are wait awhile and try again or restart the server. We suggest waiting awhile.." 10 35
            echo "The switchdrives command has failed. $HOSTNAME server failed to unmount $drivepath/$directory directory on backup drive" | mail -s "switchdrives failed on  failed on $HOSTNAME server $drivename -- drive not unmounted" $mailto
        exit 1
          fi


else
    dialog --title "$mname" --msgbox "User chose no, cancelling.." 10 35
    exit 1
fi



# Look to make sure the drive folder is available

        mount -L $drivename $drivepath

if [ ! -d $drivepath/$directory ];
        then

            dialog --title "$mname" --msgbox "Cannot mount the new drive -- Is it plugged in? Has it been preped? I'm sending an email alert to $mailto" 10 60
            echo "The switchdrives command has failed at $HOSTNAME . No usb drive is mounted or $drivepath/$directory directory on backup drive does not yet exist. Please create it." | mail -s "switchdrives failed on  failed on $HOSTNAME $drivename -- drive not mounted" $mailto
        exit

        else

            dialog --title "$mname" --msgbox "New Drive has been  mounted Press Enter to exit" 10 35
fi
 
Last edited:
I use this in /etc/fstab:
Code:
LABEL=backup       /mnt/backup     ext4    noauto,x-systemd.automount      0 0

The rest of the setup is similar to @dragonslayr . The advantage is that you can disable the storage in the GUI or from then command line, then unmount to switch drives. Upon re-enabling the storage it will get mounted automatically. I rotate my backups off-site once a month using this method.
Hmm, interesting, 2 questions. Do you ever actually use the ability to disable from the GUI?
And,,, how to disable and enable from the command line..
 
I suggest you NOT mount the backup drive in fstab. What I settled on is mounting by drive label.

Here's what I do to prep a drive and give it a drive label.

######### Prep backup drives Note: this will wipe the drive.
Code:
gdisk /dev/sd?
d
n
defaults a few times
w


# format it to ext4
mkfs -t ext4 -q /dev/sd?1 -L backup_offsite

Now that the disk has a backup label and is formatted, you can mount like this:
# Mount it and make the backup directory
Code:
mount -L backup_offsite /mnt/backup_offsite
mkdir -p /mnt/backup_offsite/dump
Then put in /etc/crontab to mount at boot
Code:
@reboot                 root    mount -L backup_offsite /mnt/backup_offsite
Note: the above command is a tad different than mine as I put this command in a script file that then runs from cron.

Then here's my relevant portion of storage.cfg

Later version of proxmox support is_mountpoint. This will stop proxmox from backing up if the drive is not mounted. Also, I disable proxmox creating the backup directory.
Edit /etc/pve/storage.cfg
Add to the bottom:
Code:
dir: backup_offsite
        path /mnt/backup_offsite
        content backup
        maxfiles 3
        shared 0
        is_mountpoint 1
        mkdir 0

Hello,

man - i can boot, that worked! Thank you VERY much

Edit1: But it does not seem to work 100%. I can boot now, so thats a plus, but VE is stating this Error inm the GUI:

unable to activate storage 'USBbackup' - directory is expected to be a mount point but is not mounted: '/mnt/backup' (500)

Edit2: It seems that i did something wrong with the cron.

Thats my row:
Code:
@reboot mount -L backup /mnt/backup
Can you tell me what would be the correct one? If i use the command (w/o the @reboot obv.) its working fine and i have the device mounted and visable in the gui.

Thanks in advance!
 
Last edited:
Hmm, interesting, 2 questions. Do you ever actually use the ability to disable from the GUI?
And,,, how to disable and enable from the command line..

Yes, the GUI is how I normally do it because I can never remember the command :cool:. It is pvesm <something>. Would check but I'm on a plane. If you leave it enabled and umount it will remount within a few seconds due to Proxmox checking status. So I disable, umount, swap, re-enable.

Probably should script it but I'm the only one doing backups so haven't bothered.
 
Hello,

man - i can boot, that worked! Thank you VERY much

Edit1: But it does not seem to work 100%. I can boot now, so thats a plus, but VE is stating this Error inm the GUI:

unable to activate storage 'USBbackup' - directory is expected to be a mount point but is not mounted: '/mnt/backup' (500)

Edit2: It seems that i did something wrong with the cron.

Thats my row:
Code:
@reboot mount -L backup /mnt/backup
Can you tell me what would be the correct one? If i use the command (w/o the @reboot obv.) its working fine and i have the device mounted and visable in the gui.

Thanks in advance!
The entry, if in /etc/crontab must be told who to run as.
Code:
@reboot                 root    mount -L backup /mnt/backup
 
Hi,
you must mount your usb drive like here explained

http://linuxconfig.org/howto-mount-usb-drive-in-linux

then you can add via GUI a new Storage Datacenter->Storage->Add->Directory

and then use the path where you mount the usbDisk.

important is you must select vzdump on the Storage window.

See here http://pve.proxmox.com/wiki/Storage_Model
I tried this. In testing to see if I could restore to a different proxmox server, it uses the wrong restore config file. It uses the config from the last backup done on the second server and I don’t know of a way to change it.
 
Hi wg0f,

I don't understand your problem, can you give a bit more details?
 

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!