mirror of
https://codeberg.org/hyperreal/admin-scripts
synced 2024-11-01 16:03:06 +01:00
Add backup-to-minio
This commit is contained in:
parent
ca7cb67a65
commit
748be3e3f0
29
bin/backup-to-minio
Executable file
29
bin/backup-to-minio
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# /etc/cron.weekly/backup-to-minio
|
||||||
|
|
||||||
|
TEMP_DIR=$(mktemp -d || echo "Failed to make temp dir"; exit 1)
|
||||||
|
chmod 700 "${TEMP_DIR}"
|
||||||
|
trap 'rm -rf "${TEMP_DIR}" ; exit 0' 0 1 2 3 15
|
||||||
|
|
||||||
|
while read -r line; do
|
||||||
|
rsync -aAX "$line" "${TEMP_DIR}" ;
|
||||||
|
done </etc/rsync-includes.txt
|
||||||
|
|
||||||
|
UNPRIV_USER=$(grep "1000" /etc/passwd | awk -F: '{print $1}')
|
||||||
|
chown -R "$UNPRIV_USER":"$UNPRIV_USER" "${TEMP_DIR}"
|
||||||
|
|
||||||
|
declare -i NUM_TX
|
||||||
|
NUM_TX=$(getconf _NPROCESSORS_ONLN)/2
|
||||||
|
|
||||||
|
if ! test -f "/home/${UNPRIV_USER}/.config/rclone/rclone.conf"; then
|
||||||
|
echo "Rclone config not found. Setup rclone first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! sudo -u "$UNPRIV_USER" rclone copy --quiet --transfers="$NUM_TX" "${TEMP_DIR}" "minio:$(hostname)"; then
|
||||||
|
echo "Error running rclone"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue
Block a user