1

I have the following script:

#------------------------ SETTINGS
FOLDER_NAME="$(date '+%Y_%b_%d')"
LOG_PATH=/home/alex/logs/backup-seafile-$FOLDER_NAME.log
DIR_PATH=/mnt/data/Backups/Seafile
FOLDER_PATH=$DIR_PATH/$FOLDER_NAME

echo "--------------------------------------------" >> $LOG_PATH
echo "[$(date '+%Y %b %d %H:%M:%S')] Running Seafile backup" | tee -a $LOG_PATH

echo "[$(date '+%Y %b %d %H:%M:%S')] Deleting old backups..." | tee -a $LOG_PATH
#find $DIR_PATH/* -type d -ctime +7 -print -exec rm -rf {} \; >> $LOG_PATH

echo "[$(date '+%Y %b %d %H:%M:%S')] Stopping seafile..." | tee -a $LOG_PATH
/opt/seafile/seafile-server-latest/seafile.sh stop
/opt/seafile/seafile-server-latest/seahub.sh stop

echo "[$(date '+%Y %b %d %H:%M:%S')] Collecting garbage..." | tee -a $LOG_PATH
/opt/seafile/seafile-server-latest/seaf-gc.sh

echo "[$(date '+%Y %b %d %H:%M:%S')] Creating backup folder..." | tee -a $LOG_PATH
mkdir $FOLDER_PATH

echo "[$(date '+%Y %b %d %H:%M:%S')] Databases..." | tee -a $LOG_PATH
mysqldump -h localhost -uUSER -pPASSWORD --opt ccnet-db > $FOLDER_PATH/ccnet-db.sql
mysqldump -h localhost -uUSER -pPASSWORD --opt seafile-db > $FOLDER_PATH/seafile-db.sql
mysqldump -h localhost -uUSER -pPASSWORD --opt seahub-db > $FOLDER_PATH/seahub-db.sql

echo "[$(date '+%Y %b %d %H:%M:%S')] Data..." | tee -a $LOG_PATH
rsync -azv --progress /mnt/data/seafile/ $FOLDER_PATH | tee -a $LOG_PATH

echo "[$(date '+%Y %b %d %H:%M:%S')] Starting seafile..." | tee -a $LOG_PATH
/opt/seafile/seafile-server-latest/seafile.sh start
/opt/seafile/seafile-server-latest/seahub.sh start

echo "[$(date '+%Y %b %d %H:%M:%S')] Backup Complete!" | tee -a $LOG_PATH

I recently noticed that I only ever had one folder and realized it was because all of the backups have the same timestamp of a past date, hence being deleted by the commented out line. I have no idea where its getting this date from or how to change it. Running mkdir normally results in a folder with the correct date. What gives?

1 Answer 1

1

The line

rsync -azv --progress /mnt/data/seafile/ $FOLDER_PATH

may be resetting the timestamp to that of seafile.

You can work around this by touch $FOLDER_PATH after the rsync.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .