usb-move.sh 663 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. set -e
  3. SRC_DIR="/media/username/SANSA"
  4. DEST_DIR="/home/powellc/var/rockbox/"
  5. FILENAME="scrobbles.tsv"
  6. WEBDAV_URL="https://box.unbl.ink/cloud/files/var/"
  7. WEBDAV_USER="colin@unbl.ink"
  8. WEBDAV_PASS=""
  9. # Wait a moment to ensure mount is complete
  10. sleep 2
  11. if [ -f "$SRC_DIR/$FILENAME" ]; then
  12. TIMESTAMP=$(date +"%Y%m%d-%H%M%S")
  13. NEW_NAME="scrobbles-$TIMESTAMP.tsv"
  14. # Backup locally
  15. mv "$SRC_DIR/$FILENAME" "$DEST_DIR/$NEW_NAME"
  16. # Send to WebDAV
  17. curl -s --netrc -T "$LOCAL_PATH" "${WEBDAV_URL}${NEW_NAME}"
  18. # Notify user
  19. curl -s -d "Backed up $FILENAME locally and sent to Webdav" https://ntfy.unbl.ink/life >/dev/null
  20. fi