Skip to content

Commit 24678b6

Browse files
xentecklardotsh
authored andcommitted
Use ISO 8601 date format for backup filenames
With previous `%D` format preventable errors like ``` tar (child): /data/backups/backup-09/05/22-03-22-03.tar.gz: Cannot open: No such file or directory ``` will occur. Let's use a more sane[^1] date format where possible. The -I flag to date(1) was added in roughly 1999[^2] and is portable across GNU coreutils and BusyBox. Piping to tr(1) to remove colons in filenames is largely a Windows-compatibility concern, as Win32 does not allow for that character in filenames[^3], and it's possible that the backups target directory could be a volume mount to a Windows host (for example on Docker Desktop For Windows). [^1]: https://xkcd.com/1179/ [^2]: https://unix.stackexchange.com/a/164834 [^3]: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions Co-Authored-By: Josh Klar <[email protected]>
1 parent 33edaf3 commit 24678b6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ appManagePy() {
478478
appBackup() {
479479
echo "Starting backup process ..."
480480
local TIMESTAMP
481-
TIMESTAMP=$(date "+%D-%H-%M-%S")
481+
TIMESTAMP=$(date -u -Iseconds | tr ':' '_')
482482
if [ -d "/tmp/backup-$TIMESTAMP" ]; then
483483
echo "Temporary backup folder for \"$TIMESTAMP\" already exists. Aborting."
484484
echo "Backup process failed. Exiting."

0 commit comments

Comments
 (0)