ttionya / vaultwarden-backup

Backup vaultwarden (formerly known as bitwarden_rs) SQLite3/PostgreSQL/MySQL/MariaDB database by rclone. (Docker)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The BACKUP_FILE_DATE_SUFFIX env variable should support a few more characters

Bakuriu opened this issue · comments

Something that has been bugging me for some time is that I'd like to use %Y-%m-%dT%H:%M as format for the date for my files, but this tool silently discards the : so instead of writing 18:17 it writes 1817.

I have read the documentation here: https://github.com/ttionya/vaultwarden-backup#backup_file_date_suffix
However I believe that it is wrong. It claims this:

Note that only numbers, upper and lower case letters, -, _, % are supported.

But this is clearly wrong!

For once, in the 20+ years I've been using linux date has always worked with, say, %H:%M. Secondly looking at the official GNU documentation for date invocation you see a clear example containing :!

Invoking date with no format argument is equivalent to invoking it with a default format that depends on the LC_TIME locale category. In the default C locale, this format is ‘'+%a %b %e %H:%M:%S %Z %Y'’, so the output looks like ‘Thu Jul 9 17:00:00 EDT 2020’.

In fact I'm pretty sure that date is quite forgiving in what it accepts.

Can we please allow at least : which is a super common separator for time? Also: instead of silently dropping stuff I suggest you throw an error. At least people know that you are restricting the input. Silently modifying the template can yield unexpected results.

I admit that I underestimated the need for custom file date suffix from the beginning. Currently, I am even using both the BACKUP_FILE_DATE and BACKUP_FILE_DATE_SUFFIX environment variables to create the file date suffix.

However, to avoid any break changes, I will add a new environment variable called BACKUP_FILE_SUFFIX, which will have a higher priority and will be used to identify the part between the file name and the extension. The implementation will be [filename].$(date +"${BACKUP_FILE_SUFFIX}").[ext]. Of course, BACKUP_FILE_SUFFIX will not restrict any input characters, but users need to be careful when modifying this environment variable to avoid the risk of continuous overwriting of backup files.

I am currently working on adding this feature and will notify you once I release the new version.

@Bakuriu

Released in v1.18.0.