25 lines
798 B
Bash
Executable file
25 lines
798 B
Bash
Executable file
#!/bin/bash
|
|
|
|
echo "Running backup at $(date)"
|
|
|
|
if [[ -v KOPIA_PG_DATABASE ]];
|
|
then
|
|
echo "Dumping database ${KOPIA_PG_DATABASE}"
|
|
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
|
|
|
|
if [[ -v KOPIA_FTP_HOST ]];
|
|
then
|
|
echo "Downloading from ftp server ${KOPIA_FTP_HOST}"
|
|
|
|
lftp -u "$KOPIA_FTP_USER","$KOPIA_FTP_PASSWORD" -e "set ssl:verify-certificate no; mirror --delete --parallel=4 --use-pget-n=10 / /backup/ftp;" $KOPIA_FTP_HOST || exit 1
|
|
fi
|
|
|
|
kopia repository connect filesystem \
|
|
--path /repository \
|
|
--override-hostname ${KOPIA_HOSTNAME} \
|
|
--override-username ${KOPIA_USERNAME}
|
|
|
|
kopia snapshot create ${KOPIA_BACKUP_PATH}
|
|
|
|
echo "Finished backup at $(date)"
|