Moved rclone.sh upload script to homelab-scripts instead of its own repo
This commit is contained in:
64
rclone.sh
Normal file
64
rclone.sh
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Rclone upload script used on TrueNAS. This and the config are on an encrypted dataset while
|
||||
# the built in functions in TrueNAS store the encryption password unencrypted in the database.
|
||||
|
||||
# Variables
|
||||
RCLONE_DIR="/mnt/data/rclone"
|
||||
RCLONE_LOGS="${RCLONE_DIR}/logs"
|
||||
RCLONE_CONFIG="${RCLONE_DIR}/rclone.conf"
|
||||
RCLONE_BIN="/usr/bin/rclone"
|
||||
RCLONE_COMMAND="${RCLONE_BIN} --config ${RCLONE_CONFIG} --log-level DEBUG --log-file"
|
||||
PIDFILE="${RCLONE_DIR}/rclone.sh.pid"
|
||||
|
||||
# removes pid file and exit cleany
|
||||
clean-up() {
|
||||
# Gzip Log files
|
||||
find ${RCLONE_LOGS} -type f ! -name '*.gz' -exec pigz "{}" \;
|
||||
# remove the pid file
|
||||
rm -f ${PIDFILE}
|
||||
# exit with clean code
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Look for exits in the program and make sure to call the clean-up function
|
||||
trap clean-up SIGHUP SIGINT SIGTERM
|
||||
|
||||
# Check to see if app is running or not
|
||||
if [ -f ${PIDFILE} ]; then
|
||||
PID=$(cat "${PIDFILE}")
|
||||
ps -p "${PID}" > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
# "Previous job, ${PID}, is already running"
|
||||
exit 1
|
||||
else
|
||||
## Process not found assume not running
|
||||
echo $$ > "${PIDFILE}"
|
||||
if [ $? -ne 0 ]; then
|
||||
# "Could not create PID file"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo $$ > "${PIDFILE}"
|
||||
if [ $? -ne 0 ]; then
|
||||
# "Could not create PID file"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Download the latest rclone binary
|
||||
#curl --silent https://rclone.org/install.sh | bash > /dev/null # This is not needed anymore since rclone is built in now and updated with TrueNAS
|
||||
|
||||
# Upload encrypted seafile files to Google Drive and BackBlaze B2
|
||||
#${RCLONE_COMMAND} "${RCLONE_LOGS}/seafile/rclone_seafile_gd_`date +%Y%m%d-%H%M%S`.log" --fast-list sync /mnt/data/seafile/ gd-crypt:Seafile
|
||||
${RCLONE_COMMAND} "${RCLONE_LOGS}/seafile/rclone_seafile_b2_`date +%Y%m%d-%H%M%S`.log" --fast-list sync /mnt/data/seafile/ b2-crypt-seafile:
|
||||
|
||||
# Upload encrypted backups to Google Drive
|
||||
#${RCLONE_COMMAND} "${RCLONE_LOGS}/backups/rclone_backups_gd_`date +%Y%m%d-%H%M%S`.log" --fast-list sync /mnt/data/backups gd-crypt:Backups
|
||||
|
||||
# Upload encrypted media to Google Drive
|
||||
#${RCLONE_COMMAND} "${RCLONE_LOGS}/media/rclone_media_gd_`date +%Y%m%d-%H%M%S`.log" --fast-list sync /mnt/media/plex/local_media/ gd-crypt:Media
|
||||
|
||||
# exit the program
|
||||
clean-up
|
||||
Reference in New Issue
Block a user