Backup directories with space in directory name

W Scott Lockwood III vladinator at gmail.com
Sat Dec 31 04:26:18 UTC 2016


That is odd. Have you tried to double escape it? You really shouldn't need
to, but it can't hurt to try. Also have you considered using something like
Amanda backup? It can back up to a share like that and handles spaces in
names just fine.

On Dec 30, 2016 21:48, "Jack McGee" <jack at greendesk.net> wrote:

> I am trying to use this perl script to backup a directory, but it fails
> with this error:
>
> jmcgee at jmcgee-desktop:~$ perl backupsystemrotate.pl
> Backing up /mnt/ntfs-d/My Documents to /mnt/media3/backups/desktop/jm
> cgee-desktop-Friday.tgz
> Fri Dec 30 21:42:57 CST 2016
>
> tar: Removing leading `/' from member names
> tar: /mnt/ntfs-d/My: Cannot stat: No such file or directory
>
> and then it proceeds to backup a directory called Documents.
>
> Adding single quotes to the line inside the double quotes gives this error:
>
> Backing up '/mnt/ntfs-d/My Documents' to /mnt/media3/backups/desktop/jm
> cgee-desktop-Friday.tgz
> Fri Dec 30 21:45:43 CST 2016
>
> tar: '/mnt/ntfs-d/My: Cannot stat: No such file or directory
> tar: Documents': Cannot stat: No such file or directory
> tar: Exiting with failure status due to previous errors
>
> Backup finished
>
>
> Using a \ instead of the space also gives another error.
>
>
> jmcgee at jmcgee-desktop:~$ cat backupsystemrotate.pl
> #!/bin/bash
> ####################################
> #
> # Backup to NFS mount script with
> # grandfather-father-son rotation.
> #
> ####################################
>
> # What to backup.
> backup_files="/mnt/ntfs-d/My Documents"
>
> # Where to backup to.
> dest="/mnt/media3/backups/desktop"
>
> # Setup variables for the archive filename.
> day=$(date +%A)
> hostname=$(hostname -s)
>
> # Find which week of the month 1-4 it is.
> day_num=$(date +%d)
> if (( $day_num <= 7 )); then
>         week_file="$hostname-week1.tgz"
> elif (( $day_num > 7 && $day_num <= 14 )); then
>         week_file="$hostname-week2.tgz"
> elif (( $day_num > 14 && $day_num <= 21 )); then
>         week_file="$hostname-week3.tgz"
> elif (( $day_num > 21 && $day_num < 32 )); then
>         week_file="$hostname-week4.tgz"
> fi
>
> # Find if the Month is odd or even.
> month_num=$(date +%m)
> month=$(expr $month_num % 2)
> if [ $month -eq 0 ]; then
>         month_file="$hostname-month2.tgz"
> else
>         month_file="$hostname-month1.tgz"
> fi
>
> # Create archive filename.
> if [ $day_num == 1 ]; then
>     archive_file=$month_file
> elif [ $day != "Saturday" ]; then
>         archive_file="$hostname-$day.tgz"
> else
>     archive_file=$week_file
> fi
>
> # Print start status message.
> echo "Backing up $backup_files to $dest/$archive_file"
> date
> echo
>
> # Backup the files using tar.
> tar czf $dest/$archive_file $backup_files
>
> # Print end status message.
> echo
> echo "Backup finished"
> date
>
> # Long listing of files in $dest to check file sizes.
> ls -lh $dest/
>
>
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailm
> an/listinfo/ubuntu-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20161230/ae85c190/attachment.html>


More information about the ubuntu-users mailing list