• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Input Tutorial: Create a loop device on /var/lib/psa/dumps as samba storage

B4c4rd1

Regular Pleskian
Hi Guys,

I have a new tutorial for you today. I will show you a samba share, how to create a loop device and then mount it and use this as internal backup space!

Advantages compared to a FTP storage:
  • Full access rights
  • Natural limitation of speed through your connection
  • No server lag during creation or restoration
  • Memory is used as normal as internal memory
  • really fast restore!
Difficulty: medium (does this tutorial only if you know what you are doing, false information can lead to data loss)
Testet on: Ubuntu 16.04 (further tests are welcome)

Now to the tutorial:

The tutorial assumes that you are using a FTP storage with samba support. For example, an FTP store by Hetzner.

Installing CIFS support:
Code:
apt install cifs-utils

# Create directories
Code:
mkdir /mnt/hetzner-backup-space

# Create cifs-credentials file
Code:
nano /mnt/backup-credentials.txt

# Insert the following
Code:
username=your_username
password=your_password

This file is used to protect your password if someone can read the fstab file.

Now you have to enter the following in the fstab:
Code:
//SAMBA_SERVER/backup /mnt/hetzner-backup-space cifs iocharset=utf8,rw,credentials=/mnt/backup-credentials.txt,cache=none,nobrl,file_mode=0660,dir_mode=0770,rsize=65536,wsize=130048,uid=0,gid=0 0 0

Now save the file and do the following to mount the samba storage:
Code:
mount -a

Now we create a loop device. To do this, we need an image file that we need to format. Execute the following command:

Code:
# create 100GB image, fast create for lage file sizes
dd if=/dev/zero of=/mnt/hetzner-backup-space/backup-fs.image bs=1024 count=0 seek=$[1024*1024*100]

# create an ext3 filesystem inside the image
mkfs.ext3 /mnt/hetzner-backup-space/backup-fs.image

Now we just need to include the formatted file as a loop device and link it to the /var/lib/psa/dumps folder:
Code:
mount -o loop /mnt/hetzner-backup-space/backup-fs.image /var/lib/psa/dumps

If you do not want to do this after each reboot, we have to add the following in the fstab * not yet tested!
Code:
# Insert after CIFS-Mount line
/mnt/hetzner-backup-space/backup-fs.image       /var/lib/psa/dumps       ext3       loop       0 0

Now you can use the samba storage as a your lokal storage.

As always, test the tutorial before in a virtual environment and to take notes.
 
Last edited:
More background knowledge: Why do I use a loop device and bind samba not directly?

Plesk creates in the dump folder during a update, backup files and uses the command chown. Chown does not work in a samba network folder. The process is interrupted and a error occur. The same happens with plesk repair.

In a loop device you can use all commands as well as the command chown. You can change the user, the group and so on.
 
Is this still the best way to do a Backup on NFS/ CIFS ? Or is there a better way now without Problems?
Maybe @IgorG has something?
 
Back
Top