How to Auto Backup Files to USB Media When Connected

'A backup is the last defense against data loss, offering a means to restore original data. You can use either a removable media such as an external hard drive or USB flash disk or a shared network folder, or a remote host to back up your data. It’s very easy (and equally essential) to automatically backup your important files without you having to remember to do so. In this article, we will learn how to auto backup data to a removable media after connecting it to your Linux machine. We will test with an external disk. This is a basic guide to get you started with using udev for real-life solutions.' -- source: https://www.tecmint.com/auto-backup-files-to-usb-media-in-linux/ Cheers, Peter -- Peter Reutemann Dept. of Computer Science University of Waikato, NZ +64 (7) 858-5174 http://www.cms.waikato.ac.nz/~fracpete/ http://www.data-mining.co.nz/

On Mon, 10 Dec 2018 10:14:28 +1300, Peter Reutemann wrote:
https://www.tecmint.com/auto-backup-files-to-usb-media-in-linux/
In summary, it involves creating a custom udev rule which runs automatically when the USB stick is inserted. This is an entirely reasonable way to do it. Unfortunately, what’s missing is provision for unmounting the stick when the backup is complete, and some way of notifying the user that it is safe to remove it.

Unfortunately, what’s missing is provision for unmounting the stick when the backup is complete, and some way of notifying the user that it is safe to remove it.
In a non-GUI environment, then I guess if they install "Policy Mount<https://linux.die.net/man/1/pmount>"... sudo apt install pmount ...then use the pumount<https://linux.die.net/man/1/pumount> command line utility of the pmount application. The pumount command could be invoked with a bash script to do the unmounting of the USB drive without requiring priv. I recently opted for... https://github.com/raamsri/automount-usb ...as a better tool for mounting USB drives over... usbmount<https://github.com/rbrito/usbmount> - automatically mount and unmount USB mass storage devices I combine automount-usb with pumount to do both the automatic mounting and manual unmounting of USB drives on a Debian server. cheers, Ian.

On Mon, 10 Dec 2018 02:56:26 +0000, Ian Stewart wrote:
I combine automount-usb with pumount to do both the automatic mounting and manual unmounting of USB drives on a Debian server.
I have a regime for making backups of my user files, originally onto a bunch of DVDs (until that grew to close to a dozen discs), more recently onto USB sticks. Mounting a stick from non-root is as easy as communicating with the UDisks daemon with the “udisksctl” command, e.g. udisksctl mount -b /dev/sdc1 replacing “mount” with “unmount” to correspondingly unmount the stick. For OS configs on my two main machines, each /etc directory is simply rsync’d to a backup directory on the other machine. I don’t normally bother backing up entire OS installations.
participants (3)
-
Ian Stewart
-
Lawrence D'Oliveiro
-
Peter Reutemann