distribution/packages/sysutils/rclone/sources/cloud_backup

29 lines
826 B
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: Apache-2.0
# Copyright (C) 2020-present Fewtarius
CONFIGPATH="/storage/.config"
if [ -e "${CONFIGPATH}/rsync.conf" ]
then
source ${CONFIGPATH}/rsync.conf
fi
# If rsync.conf is missing variables set defaults
MOUNTPATH="${MOUNTPATH:=/storage/cloud}"
SYNCPATH="${SYNCPATH:=GAMES}"
BACKUPPATH="${BACKUPPATH:=/storage/roms}"
RSYNCOPTSBACKUP="${RSYNCOPTSBACKUP:=-raiv --prune-empty-dirs}"
echo -e "=> ${OS_NAME} CLOUD BACKUP UTILITY\n"
echo "Mounting ${MOUNTPATH}" 2>&1
rclonectl mount ${MOUNTPATH} 2>&1
echo "Backing up data from ${BACKUPPATH} to ${MOUNTPATH}/${SYNCPATH}" 2>&1
rsync ${RSYNCOPTSBACKUP} --include-from="${CONFIGPATH}/rsync-rules.conf" ${BACKUPPATH}/ ${MOUNTPATH}/${SYNCPATH}/ 2>&1
echo "Unmounting ${MOUNTPATH}" 2>&1
rclonectl unmount ${MOUNTPATH} 2>&1
sleep 3
clear