Skip to content

Rsync Backup Fails with Question Mark

Hello to all the readers!

I regular backup up my system to an external hard disk. I work with System and Software everyday. Therefore, you will know that it is a very important duty to backup the data to some external device for emergency.

I use the most popular rsync tool in order to synchronize the entire home directory. I store all my documents and stuff in home directory itself and store it in on a separate disk partition. The main advantage of rsync is that it does not copy already present files/directories in destination. But rather it will just copy new or modified files.

The following command does the job:

rsync -auv --progress --delete /home/theunknown/ /run/media/theunknown/HDD/backup-of-home/

This will copy all the files including hidden files and directories. Also, it will delete all those files from the HDD that I deleted since last backup in my home folder. Just like I didn’t want certain files, so it makes sense to delete it from destination as well. This is what is called synchronization.

But today while performing backup, it failed for some files.

rsync -auv --progress --delete * /run/media/theunknown/HDD/backup-of-home/Documents/
                                                               
Unexpected remote arg: wp-login.php?redirect_to=https:%2F%2Fayurvedaplace.com%2F2011%2F02%2F08%2Funresolved-bad-emotions%2F.html
rsync error: syntax or usage error (code 1) at main.c(1508) [sender=3.2.7]

The Question mark ? in the filename is causing the problem. I thought it could be other special characters including percent symbol %, equal to sign = but I was able to copy files with such characters. So, it was only the question mark character that was failing rsync to copy the file.

Beware, joke ahead! Looks like rsync fails to find answer to the question 😀

Okay, so jokes apart, I could find that it is because rsync fails to create a file with question mark on NTFS filesystem. The external HDD has come formatted with NTFS.

/run/me/t/HDD/Documents> touch 'test-file?'
touch: cannot touch 'test-file?': Invalid argument

Also, NTFS does not support colon : character as well in the filename.

/run/me/t/HDD/Documents> touch 'test-file:'
touch: cannot touch 'test-file:': Invalid argument

So, what I have to do is either create a zip of the affected files and copy the zip to HDD or rename files and then copy them. But at-least rsync was is not the culprit.