The next time you connect your external hard disk or whatever device you configured to the system, all your documents from the specified location should be auto backed up to it. Next, reload udev rules using the following command. Then make the script executable with the following command. usr/bin/rsync -auz "$MOUNT_POINT" "$BACKUP_SOURCE" & /bin/umount "$BACKUP_DEVICE" bin/mount -t auto “$BACKUP_DEVICE” “$MOUNT_POINT” #check if mount point directory exists, if not create it #!/usr/bin/bashīACKUP_SOURCE="/home/admin/important" BACKUP_DEVICE="/dev/external1" MOUNT_POINT="/mnt/external" Now copy and paste the following script, make sure to replace values of BACKUP_SOURCE, BACKUP_DEVICE, and MOUNT_POINT in the script. Now create an auto backup script that will auto backup files to removable USB when connected to the system. RUN: specifies a program or script to execute as part of the event handling.Then add the following rule in it: SUBSYSTEM="block", ACTION="add", ATTRS: matches sysfs attribute values of the event device, which is the device vendor ID. The order in which rules are parsed is important you should always create custom rules to be parsed before the defaults. The 10 in the filename specifies the order of rules execution. $ lsusbįrom the output of the above command, our device vendor ID is 125f, which we will specify in the udev rules as explained below.įirst, remove the connected media from the system and create a new udev rules file called 10.les under the directory /etc/udev/rules.d/. Connect the external disk to the running system and run the following lsusb command to identify its vendor and product ID.įor the testing purpose, we will be using 1TB external hard disk as shown. We can use this feature to execute a backup script after adding a removable media to the running system.īefore we configure the actual rule for device event handling, we need to provide udev some attributes of the removable media that will be used for the backup. Udev is a device manager that enables you to define rules that can among others, trigger execution of a program or script when a device is added to or removed from a running system, as part of the device event handling. How to Configuring Udev Rules for Removable Media This is a basic guide to get you started with using udev for real-life solutions.įor the purpose of this article, we need a modern Linux system with: In this article, we will learn how to auto backup data to a removable media after connecting it to your Linux machine. Read Also: 24 Outstanding Backup Tools for Linux Systems in 2018 It’s very easy (and equally essential) to automatically backup your important files without you having to remember to do so. 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. A backup is the last defense against data loss, offering a means to restore original data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |