1

so here's the script that i am trying to get it work:

#!/bin/bash
filePath="$1"
fileName="$( basename "$filePath" )"
backupDir="/my/backup/dir/${fileName}-backups/"
dateTime=$( date "+%d.%m.%Y_%H:%M:%S" ) 

# Check if backup folder exists if not create them
if [ ! -d "$backupDir" ]; then
  mkdir "$backupDir"
fi

# Create the Backup in a zip-file
zip -r "${backupDir}${fileName}-${dateTime}.zip" "$filePath" 

This error appears:

zip I/O error: Protocol error
zip error: Could not create output file (/my/backup/dir/filename-backups/filename-06.04.2014_18:54:58.zip)

The problem seems to be the "dateTime" variable. Without this variable the script runs faultless.

EDIT: Ok the problem are the double points in the date string:

dateTime=$( date "+%d.%m.%Y_%H:%M:%S" )  

If i change it to

dateTime=$( date "+%d.%m.%Y_%H-%M-%S" )  

it works for me. Not really nice, but if there no other possibility...

1 Answer 1

1

It's probably because ZIP is dos/windows-centric. In Windows, : is disallowed in filenames since it's used as separator between drive letter and path (C:\).

Unless you really need zip, I recommend using tar with gzip or xz compression instead.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .