Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
laborb-sb opened this issue Oct 28, 2018 · 5 comments · May be fixed by #191
Open

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

laborb-sb opened this issue Oct 28, 2018 · 5 comments · May be fixed by #191

Comments

@laborb-sb
Copy link

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!

@dusanx
Copy link

dusanx commented Nov 18, 2018

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
}

@laborb-sb
Copy link
Author

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.

@generic-github-user
Copy link

generic-github-user commented Apr 2, 2019

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
Copy link

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.

@sheridans sheridans linked a pull request Dec 18, 2019 that will close this issue
@matiasfrndz
Copy link

matiasfrndz commented Mar 27, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants