This repository has been archived on 2024-12-15. You can view files and clone it, but cannot push or open issues or pull requests.
kopia/run-backup.sh

30 lines
810 B
Bash
Raw Permalink Normal View History

2023-08-18 19:19:37 +00:00
#!/bin/bash
2023-08-19 10:03:58 +00:00
echo "Running backup at $(date)"
2023-08-18 19:19:37 +00:00
if [[ -v KOPIA_PG_DATABASE ]];
then
2023-08-19 10:03:58 +00:00
echo "Dumping database ${KOPIA_PG_DATABASE}"
2023-08-18 19:19:37 +00:00
PGPASSWORD=$KOPIA_PG_PASSWORD pg_dump --host=$KOPIA_PG_HOST --username=$KOPIA_PG_USER $KOPIA_PG_DATABASE > /backup/database/$KOPIA_PG_DATABASE.sqldump || exit 1
fi
2023-08-17 15:00:22 +00:00
2023-08-19 10:03:58 +00:00
if [[ -v KOPIA_FTP_HOST ]];
then
echo "Downloading from ftp server ${KOPIA_FTP_HOST}"
lftp -u "$KOPIA_FTP_USER","$KOPIA_FTP_PASSWORD" $KOPIA_FTP_HOST <<EOF
set ssl:verify-certificate no
mirror --delete --parallel=4 --use-pget-n=10 / /backup/ftp;
exit
EOF || exit 1
fi
2023-08-17 15:36:27 +00:00
kopia repository connect filesystem \
--path /repository \
--override-hostname ${KOPIA_HOSTNAME} \
--override-username ${KOPIA_USERNAME}
2023-08-17 15:00:22 +00:00
kopia snapshot create /backup
2023-08-19 10:05:05 +00:00
echo "Finished backup at $(date)"