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...

up vote 1 down vote accepted

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.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.