Delete oldest backup if not enough disk space. If backup_age < min_backup_age, stop the script. Last_backup_mod_time = the last modification time of backup_file_full_path (the newest file found in that folder that contains source_file_name)īackup_age = source_file_mod_time - last_backup_mod_time # Guard clause against a minimum backup age. Send notification to user: "Not enough free space on USB to backup source_file_full_path."Ĭreate the folders to the path backup path.Ĭall # Archive source file to backup with the source file last mod time attached to name. # Guard clause against not enough disk space: If any file at backup_file_full_path != contain source_file_name: # Guard clause against no backups folder or older backups existing. Source_file_mod_time = source_file_full_path/source_file_name modification time. # Assign source file modification time to variable: Source_file_size = source_file_full_path/source_file_name file size Usb_free_space = the amount of free space on last_usb_drive_name # Assign free space on backup drive to variable: If last_usb_drive_name != contain backup_drive_tag, stop the scriptīackup_file_full_path = source_file_full_path with source_file_drive replaced by last_usb_drive_name Last_usb_drive_name = drive name of the usb that was plugged in. Min_backup_age: The minimum time difference between source of truth file & last backup: Source_file_full_path: The full path to the source file.īackup_drive_tag: The backup USB tag: If the tag is contained within the USB drive name, backup the source file. Source_file_name: The name of the source file to be backed up. Source_file_drive_name: The drive that contains the source file. Keep backups tagged with the source file modification time. Once the USB is full, delete the oldest archive and replace it with the newest. Purpose: Keep an archived backup of a file (the source of truth file) on an external USB. What’s the best existing tools to get the functionality the simplest? Bash shell script: For what it’s worth, this is the logic I mapped out. Before reading these last comments I wrote out the logic I need, and was about to venture to make my first bash shell script to do the job.īut, likely there is a better way with existing tools. I think I’m trying to reinvent the wheel. Some way to assign file modification times to variables and run logic against them. ~]$ gdbus call -e -d -o /org/freedesktop/Notifications -m MyApp 0 IconAlert "Watch Out!" "Something odd is going on, please stay vigilant and pay attention!" '' '' 0 Some kind of way to send notifications to the user. acpid - non-keyboard event handler (special keys such as volume, Fn keys, brightness, killswitches).systemd will be good enough, can trigger services on device events, socket connection events, timer events, other services state changes.Some kind of background daemon to watch for the trigger event. Pattern match storage device name to contain a string. Trigger event: When a new USB or storage device is plugged in.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |