For transcribing satellite QSOs I normally record the audio using the built-in feature of the ICOM IC-9700 which writes .wav files to a SD card. To archive those they are copied to some network storage on a regular basis. To automate this process I made some scripts that take care of this autmatically as soon as the SD card is mounted. The basics are outlined in [1].
The basis is a script which mounts the target network drive and then rsyncs the contents (i.e. basically copying all new content over). After sync it unmounts the USB drive with SD card and sends a message to the GNOME notification panel. The code is as follows:
#!/bin/sh
# sudo systemctl list-units -t mount
# Unit: media-USER-SOMEID
# Label: XXXX-YYYY
mount /media/USER/Home/
sleep 1
rsync -r /media/USER/XXXX-YYYY/IC-9700/Voice/ /media/USER/Home/SAT\ Recordings/
sleep 1
udisksctl unmount -b $(mount | grep "XXXX-YYYY" | cut -d" " -f1)
sleep 1
DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/USERID/bus notify-send 'SAT Recordings succesfully synced'
exit 0
The labels can be found using the command from the comments section of the script. USER and USERID have to be replaced by the corresponding user name and user id.
The automation of executing this on mount automagically is a systemd service which is executed on mounting. This requires setting Requires, After and WantedBy in the service description file. After reloading the systemd units this should be executed as soon as the USB drive with the SD card having the configured label is plugged. The systemd service is configured like this:
[Unit]
Description=Auto sync SAT recordings
Requires=media-USER-XXXX\x2dYYYY.mount
After=media-USER-XXXX\x2dYYYY.mount
[Service]
ExecStart=/home/USER/bin/sync_sat_recordings.sh
WorkingDirectory=/home/USER/bin
User=USER
Group=users
Environment="DISPLAY=:0"
[Install]
WantedBy=media-USER-XXXX\x2dYYYY.mount
ExecStart contains the path to the script described above. For this to work the script needs to be executable of course.
References
[1]: https://askubuntu.com/questions/25071/how-to-run-a-script-when-a-specific-flash-drive-is-mounted