1

I intend to copy files from one Kubuntu PC to the Samba share of a second PC as a backup. For this purpose I am using a backup GUI tool.

I would like to mount the samba share to a mount point on the source system (e.g. using /etc/fstab or eventually using a command line). This is not too difficult.

However what happens if the other PC isn't available? The mount point then would be a plain folder and I would flood my small local disk with backup files instead of copying to the remote share.

This once happened to me with an unavailable local disk. However with a second system this accident is much more likely.

How can I prevent that disaster?

1

I could solve this by removing any writing rights from the dummy mount point folder. This way, copying files fails if mounting was not successful. For changing the access rights I used Dolphin's context menu.

  • Be careful, though, as mounting ext2/3/4 filesystems seems to use these permissions, which will break your setup. – user595510 Feb 17 '17 at 23:18
  • Better would be to mount a tmpfs filesystem on the mountpoint with options -o size=64,.... By mounting as tmpfs it bypasses the disk, and by limiting the size of the mountpoint, files will not take up memory/swap when mounting the real filesystem fails. Then you can still own the directory with proper permissions. – Hydranix Mar 9 '17 at 21:40
1

I asked a very similar question on serverfault some years ago: https://serverfault.com/q/337602/14942.

There are 5 ways that I thought of, with some additional variations left as an exercise for the reader.

Choices, assuming the backup filesystem is to be mounted at /mnt/backups:

  1. Monitor /mnt/backups and ensure it's not root. Perhaps a cron job.

  2. Move the mount point into a smaller separately mounted filesystem. Use /mnt/protected/backups instead, and mount /protected first to a small filesystem, perhaps a loop mount to a local file so it is much less likely to fail.

  3. Chmod a-rwx /mnt/backups (the root filesystem mount point). (This is the currently accepted answer.)

  4. On the mounted tree create a directory called "Backups", then soft link ln - s /mnt/backup/Backups /Backups. Using /Backups for backups will fail unless the /mnt/backup is mounted, since the local tree doesn't contain the sub-directory.

  5. Performing a check that the directory is correctly mounted in the backup script. (something like mountpoint -q /mnt/backups || mount /mnt/backups || exit)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.