-   Linux - General (
-   -   PDF files not being backed up correctly by rsync. Viewers unable to open them. (

powerpleb 06-02-2008 06:33 PM

[SOLVED] PDF files not being backed up correctly by rsync. Viewers can't open them.
I have a lot of PDF documents in my ~/Documents folder and I also have rsync scheduled to do a daily backup of that folder (among others).

When I looked at the backed up files I noticed that some of their icons have an 'X' in front of them. I tried to open these files with Evince and was given this error:

Unable to open document. Unknown MIME Type.
So I tried ePDFviewer instead and recieved this error:

Failed to load document '/path/file.pdf'.
No error.
I tried pdfinfo and received this error:

Error: Couldn't open file 'file.pdf'

This only happens with about half of the PDFs that have been backed up. Others work fine.

All of these documents are working fine in my home folder.

It looks to me like rsync isn't writing these files correctly.
Any idea what going on?

billymayday 06-02-2008 06:48 PM

Can you post the output of

ls -l

of the relevant directory

and also post the rsync command line you are using for backup

powerpleb 06-02-2008 06:58 PM

Thanks for the fast reply.

andrew@andrew-desktop:/media/maxtor/andrew/Documents/LIN1NLA$ ls -l
total 15976
-rw------- 1 root root    85955 2008-04-25 11:42 Assignment11.pdf
-rw-r--r-- 1 root root    15328 2008-04-27 13:00 Assignment2.odt
-rw------- 1 root root  106167 2008-04-25 11:42 Consonant_Chart1.pdf
-rw-r--r-- 1 root root    15624 2008-04-25 11:42 diphthongs.gif
-rw-r--r-- 1 root root    45963 2008-04-25 11:42 indiv_authorship.pdf
-rw------- 1 root root    59506 2008-04-25 11:42 IPA_chart_%28C%2920051.pdf
-rw------- 1 root root  490425 2008-04-25 11:42 Ladefoged_2000.pdf
-rw-r--r-- 1 root root 13662560 2008-04-25 11:42 LIN1NLAW1L1.MP3
-rw-r--r-- 1 root root    18461 2008-04-25 11:42 Monophthongs_Cox0.gif
-rw-r--r-- 1 root root  103578 2008-04-25 11:42 Phoneme_lecture_example.pdf
-rw-r--r-- 1 root root    92287 2008-04-25 11:42 Phonemics.pdf
-rw------- 1 root root    86726 2008-04-25 11:42 Readings.pdf
-rw-r--r-- 1 root root    38591 2008-04-25 11:42 Sound_of_the_World.pdf
-rw-r--r-- 1 root root  124507 2008-04-25 11:42 Speech_acquisition.pdf
-rw-r--r-- 1 root root  131868 2008-04-25 11:42 Suprasegmentals0.pdf
-rw-r--r-- 1 root root  341383 2008-04-25 11:42 Tabain_20080.pdf
-rw------- 1 root root  231467 2008-04-25 11:42 Tabain_2008.pdf
-rw------- 1 root root  108906 2008-04-25 11:42 Tutorials_Consonants%26Vowels0.pdf
-rw------- 1 root root  108906 2008-04-25 11:42 Tutorials_Consonants%26Vowels.pdf
-rw-r--r-- 1 root root    95884 2008-04-25 11:42 Tutorials_Suprasegmentals0.pdf
-rw------- 1 root root    53541 2008-04-25 11:42 UnitGuide.pdf
-rw------- 1 root root  107642 2008-04-25 11:42 Vowel_chart0.pdf
-rw------- 1 root root    96612 2008-04-25 11:42 Vowels.pdf

In this folder for example Assignment11.pdf are Constonant_Chart1.pdf don't work. But indiv_authorship.pdf is fine. Looking at it, I can see that all the pdfs that don't work are missing the two r values. What does that mean?

This is the script that performs the backup tasks. I used /etc/anacrontab to schedule it to happen daily.

# /usr/local/bin/
# - This script backs up users Documents folders to the internal drive then backs up the internal drive to the external
# USB drive.
# /home/andrew/Documents (small)
# /home/gemma/Documents (very small)
# /media/sdb5 (very large)
# - must be executed by root as it mounts the external drive
# - other dirs (video, tgz, etc.) must be updated by hand
echo ""
echo "BACKUP SCRIPT: Backs up contents of /dev/sdb5 to Maxtor external hard disk"
echo "-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=++=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-=+=-"
echo "[`date`] rsync backup tasks starting" >> /var/log/rsync.log
echo ""
echo "(1) Mounting the external hard disk..."
echo ""
mount -vt ext3 LABEL=maxtor /mnt/maxtor > /dev/null
if [ $chkmnt -eq 0 ] ; then
  echo ""
  echo ""
  echo "(2) Backing up docs..."
  echo ""
  rsync -urt --progress --delete /home/andrew/Documents /media/sdb5/andrew
  rsync -urt --progress --delete /home/gemma/Documents /media/sdb5/gemma
  echo ""
  echo ""
  echo "(3) Backing up other stuff..."
  echo ""
  rsync -urt --progress --delete /media/sdb5/ /mnt/maxtor/
  echo ""
  echo ""
  echo "(4) Unmounting the external hard disk..."
  echo ""
  umount -v /mnt/maxtor
  echo ""
  echo "[`date`] Backup was successful. Exit status $ret_val" >> /var/log/rsync.log
  echo "All done."
  echo ""
  echo ""
  echo ""
  echo "External hard disk did not mount or is in use. Exiting..."
  echo "[`date`] Drive did not mount or was already mounted! Backup aborted with exit status $chkmnt" >> /var/log/rsync.log

According to my log file it has been backing up every day without issue.

powerpleb 06-02-2008 07:10 PM

Now I feel stupid.

I tried

sudo evince file.pdf
and they all work fine.
Thanks for your help

billymayday 06-02-2008 07:11 PM

Yep - you've changed the owner to root and on the file you're having trouble with, only root has read access.

First, in that directory (as root) do

chmod 755 *

You probably want to change owner as well. I don't know what group your files would be, but as your user, type

touch test && ls -l test

to see what your group is (in the listing you gave above, the first "root" is the user and the second is the group"


chown username:groupname *

where username and groupname come from the touch line above (I'd assume andrew:andrew or andrew:users)

Next time you use rsync, add the "a" option, it does a few things, but most importantly it preserves owners and permissions.


rsync -aurt --progress --delete /home/andrew/Documents /media/sdb5/andrew

All times are GMT -5. The time now is 08:10 PM.