Scripts to do backups of nextcloud data, database and nextcloud files
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nextcloud-backups/logger.sh

24 lines
630 B

#!/bin/bash
PATH=$PATH:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
#Use ./logger.sh <logfile>
# Log parameters
REMOTE_SERVER="remote.example.com"
REMOTE_PATH="/path/to/remote/store/logs/"
PUBLIC_LOG_URL="https://example.com/hostname/"
LOG_PRESERVE_DAYS=30
# create remote folder to store logs if not exist
ssh $REMOTE_SERVER "mkdir -p $REMOTE_PATH"
# Copy local logfile to remote destination
scp $1 "$REMOTE_SERVER:$REMOTE_PATH"
# Clear x days old remote logs
ssh $REMOTE_SERVER 'bash -s' << EOF
find $REMOTE_PATH -maxdepth 1 -mtime +$LOG_PRESERVE_DAYS -exec "rm" -R {} \;
EOF
# return final log url
echo $PUBLIC_LOG_URL$1