Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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