rsync-time-backup icon indicating copy to clipboard operation
rsync-time-backup copied to clipboard

Log filename does not match directory name

Open yorkday opened this issue 6 years ago • 3 comments

Sometimes my log filenames do not match the directory names. Is the same timestamp parameter not being passed to both?

E.g. Directories: d--------- 17 root root 4096 Apr 17 00:07 2018-04-17-170953 d--------- 17 root root 4096 Apr 18 00:07 2018-04-18-183111 d--------- 20 root root 4096 Apr 20 12:55 2018-04-20-220250 d--------- 22 root root 4096 Apr 21 13:05 2018-04-22-000006 d--------- 22 root root 4096 Apr 22 00:06 2018-04-23-000006 d--------- 22 root root 4096 Apr 23 18:36 2018-04-24-000006 d--------- 18 root root 4096 Apr 24 15:45 2018-04-25-000007 d--------- 20 root root 4096 Apr 26 14:37 2018-04-27-000007 d--------- 17 root root 4096 Apr 27 12:49 2018-04-28-000007 d--------- 18 root root 4096 Apr 28 12:22 2018-04-29-000007 d--------- 18 root root 4096 Apr 30 00:07 2018-05-01-000007 d--------- 17 root root 4096 May 1 19:39 2018-05-02-000007 d--------- 14 root root 4096 May 2 14:59 2018-05-03-000014 d--------- 17 root root 4096 May 3 21:46 2018-05-03-221643

Log files in bold not matching exactly: -rw-r--r-- 1 root root 6598 Apr 17 20:04 2018-04-17-170953.log.gz -rw-r--r-- 1 root root 328 Apr 18 18:31 2018-04-18-183111.log.gz -rw-r--r-- 1 root root 558 Apr 20 22:04 2018-04-20-220250.log.gz -rw-r--r-- 1 root root 324 Apr 22 00:00 2018-04-22-000007.log.gz -rw-r--r-- 1 root root 325 Apr 23 00:00 2018-04-23-000007.log.gz -rw-r--r-- 1 root root 367 Apr 24 00:00 2018-04-24-000006.log.gz -rw-r--r-- 1 root root 491 Apr 25 00:02 2018-04-25-000007.log.gz -rw-r--r-- 1 root root 509 Apr 27 00:02 2018-04-27-000007.log.gz -rw-r--r-- 1 root root 795 Apr 28 00:10 2018-04-28-000007.log.gz -rw-r--r-- 1 root root 435 Apr 29 00:00 2018-04-29-000007.log.gz -rw-r--r-- 1 root root 325 May 1 00:00 2018-05-01-000007.log.gz -rw-r--r-- 1 root root 417 May 2 00:00 2018-05-02-000007.log.gz -rw-r--r-- 1 root root 351 May 3 00:00 2018-05-03-000014.log.gz -rw-r--r-- 1 root root 598 May 3 22:18 2018-05-03-221644.log.gz

yorkday avatar May 03 '18 12:05 yorkday

Looks like destination folder and log names are handled separately which is causing the problem.

One interpretation is that the log is definitely created at a later time in the script than the folder creation, so they are technically correct to have different timestamps.

However for readability, I would like the log and directory timestamps to be the same, so I know which log relates to which backup folder exactly.

Line 268: NOW=$(date +"%Y-%m-%d-%H%M%S")

Line 274: DEST="$DEST_FOLDER/$NOW"

Line 391: LOG_FILE="$LOG_DIR/$(date +"%Y-%m-%d-%H%M%S").log"

Line 391 should perhaps read as: LOG_FILE="$LOG_DIR/$NOW.log"

yorkday avatar May 03 '18 12:05 yorkday

Yes I think that would make sense to re-use the $NOW variable, assuming it's always defined by the time LOG_FILE is set.

laurent22 avatar May 03 '18 13:05 laurent22

Agreed. The $NOW variable might need to be defined and moved earlier in the code to be safe, otherwise in future if you included additional logging before creating the destination directory, it might not be set.

yorkday avatar May 03 '18 13:05 yorkday