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

FreeBSD 11.2: "[WARNING] Could not parse date"

Open laborb-sb opened this issue 5 years ago • 5 comments

Do I need special dependencies for the backup expiration logic? In FreeBSD 11.2 I get the error message "Could not parse date" and the default expiration strategy is not implemented.

Thanks for any help!

laborb-sb avatar Oct 28 '18 19:10 laborb-sb

echo $OSTYPE returns small letters id, for example 'freebsd11.2', while script expects FreeBSD* string. In fn_parse_date() either change FreeBSD* to freebsd* or add another line below it with the right string. Kind of diff below, makes rsync-time-backup work well.

fn_parse_date() {
        # Converts YYYY-MM-DD-HHMMSS to YYYY-MM-DD HH:MM:SS and then to Unix Epoch.
        case "$OSTYPE" in
                linux*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;;
                cygwin*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;;
                darwin*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;;
                FreeBSD*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;;
+               freebsd*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;;
        esac
}

dusanx avatar Nov 18 '18 12:11 dusanx

Thanks, that solves the problem! I would assume that this is a bug. I can't imagine 'echo $OSTYPE' returning capital letters under certain conditions.

laborb-sb avatar Nov 20 '18 15:11 laborb-sb

I am also having this issue. I tried adding the code above, saving, and relaunching the command prompt, but I was met with the same error. I also tried clearing all the existing backup files and the log files in my user directory, but this did not resolve the issue. I'm not sure if this will cause any issues with making backups other than the expiration policies, but it would be better if I could fix it. I would appreciate any help anyone could give.

Edit: I also tried replacing

cygwin*) date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s ;;

with

cygwin*) date -d "%Y-%m-%d-%H%M%S" "$1" "+%s" ;;

since echo $OSTYPE returns cygwin (I am running rsync though cygwin) so that the date format matches the one of the backup folder timestamps. This did not work either.

Edit2: I also tried adding freebsd*) date -j -f "%Y-%m-%d-%H%M%S" "$1" "+%s" ;; and cygwin*) date -u +"%Y-%m-%d-%H%M%S" "$1" "+%s" ;; individually but neither of these worked. I was able to fix the problem by removing the $OSTYPE switch case - see below.

generic-github-user avatar Apr 02 '19 01:04 generic-github-user

I was able to resolve the issue for the time being with the help of tehZevo by replacing the switch case in the fn_parse_date() function as such:

fn_parse_date() {
	date -d "${1:0:10} ${1:11:2}:${1:13:2}:${1:15:2}" +%s
}

This would need to be changed if running rsync natively or though another program than cygwin. It appears that $OSTYPE was returning a null value and this was causing fn_parse_date() to not return a proper date. By ignoring $OSTYPE we prevent the ""[WARNING] Could not parse date" error from being thrown.

generic-github-user avatar Apr 02 '19 21:04 generic-github-user

I have the same issue:

$ echo $OSTYPE
freebsd11.4

The pull request #191 from @sheridans solved it for me. @laurent22 , will you accept the pull request?

matiasfrndz avatar Mar 27 '21 10:03 matiasfrndz