Backup for VM guests

Recommend using the built in Veeam VM backup solutions.


Backup for standalone eg a raspberry pi

Recommend using RonR-Rpi-image-util scripts to do a complete image backup.  Can either backup to USB or to UNC network share. There is a module called cifscloak which stores the credentials to sign into the share in an obfuscated state, and also manages mounting of the share to /mnt/bellsbackup-veeam directory.


#install pip

sudo apt-update

sudo apt-get -y pip


#install cifscloak

sudo pip3 install git+https://github.com/sudoofus/cifscloak.git                   <- it will error on sqlite - ignore this as it comes included with python3

sudo pip install cifscloak


#set up mount point

sudo mkdir /mnt/mylinuxbackup-veeam

sudo cifscloak addmount -n mylinuxbackup -veeam -i [Insert BACKUP Server Name] -s [Insert Share Name] -m /mnt/mylinuxbackup-veeam -u [Insert usernamer name to access share]          <- will prompt for password


#test the mounting

sudo cifscloak mount -a         <- mount

ls -al /mnt/mylinuxbackup-veeam   <- make sure we can see files over the network

sudo cifscloak mount -a -u      <- dismount


#set up automount service

sudo cifscloak systemdfile -a > ~/cifscloak.service

sudo cp ./cifscloak.service /etc/systemd/system

sudo systemctl enable cifscloak

sudo systemctl start cifscloak              <- start the service

ls -al /mnt/mylinuxbackup-veeam               <- make sure we can see files over the network from the automounted mount point.


#set up cron job (job scheduler)

sudo crontab -e                             <- if prompted, select nano as the editor (usually option 1)


enter in the cron job as follows - runs at 2pm every week day

0 14 * * 1-5 /home/pi/bin/image-util/image-backup -i /mnt/mylinuxbackup-veeam/"MyLinuxComputerName_$(date +\%Y-\%m-\%d_\%H\%M).img"



Restoring raspberry from standalone backup.


If you just want to restore a file or two, or even a directory, the best way is to mount the .img file. Do this from the pi. 

If you wish to restore the entire backup image to a new SD card you need to do this from a PC. 


#Restore file/folder on the pi by mounting the .img file. 

sudo mkdir /tmp/imgmount                               <- create a temporary mount point

ls -al /mnt/mylinuxbackup-veeam                           <- list the backups in the backup location

sudo /home/pi/bin/image-util/image-mount imagefile mountpoint     <- mount the image specified to the mountpoint. 

#eg sudo /home/pi/bin/image-util/image-mount /mnt/mylinuxbackup-veeam/MyLinuxComputerName_2024-05-01_1400.img /tmp/imgmount/

#copy the files/directories you need from/tmp/imgmount/blahblah to whereever you need to copy. 

#Eg if you need to restore a web file, sudo cp /tmp/imgmount/var/www/html/assets/json/Templates.json /var/www/html/assets/json/Templates.json 


#when finished, unmount using the following

sudo umount /tmp/imgmount/

sudo losetup -d /dev/loop0



#Restoring entire backup needs to be done from another computer. 

Copy/paste the .img file from the backup server to your local computer: RDP to Veeam, browse to the backup folder, copy the .img file, minimise RDP, browse to a folder on your local computer, paste.  

Insert an SD card into your local computer. 16GB or greater is best - the restore process will expand the volume to consume the entire storage available.

Use Raspberry Pi Imager  (downloadable from https://www.raspberrypi.com/software/) -> Click Choose OS -> Use Custom -> select the .img file you pasted to your local folder above -> Click choose storage and select the SD card.