使用脚本创建的文件夹具有错误的修改时间戳

使用脚本创建的文件夹具有错误的修改时间戳

我有以下脚本:

#------------------------ 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

我最近注意到我只有一个文件夹,并意识到这是因为所有备份都具有过去日期的相同时间戳,因此被注释掉的行删除。我不知道它从哪里得到这个日期或如何更改它。运行 mkdir 通常会生成具有正确日期的文件夹。是什么赋予了?

答案1

线路

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

可能会将时间戳重置为 的时间戳seafile

touch $FOLDER_PATH您可以在后解决此问题rsync

相关内容