You are not logged in.

#1 2020-01-14 15:08:46

Vincintosh
Member
Registered: 2017-10-13
Posts: 18

I/O error while rsyncing on an SD card

Hello everyone. Since I use multiple laptops, I'm trying to set up a syncing script that syncs bidirectionally my Documents folder with an SD card (not a USB stick, so that the SD card can sit flush in the SD card readers of my laptops while in use). I would like to do that automatically everytime said SD card is mounted. But before linking a script to a udev rule or having a script run automatically on login to check if the SD is mounted, I need of course to make sure that rsync can actually sync the files both directions. So I've set up a prototype script ("DocSD" is the label I gave to the partition on the SD card):

#! /bin/bash

#this checks if the SD card is mounted and gathers path
SDPATH=$(lsblk | grep mmc | grep 'DocSD' | awk {'print $7'})

#colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BRED='\033[1;31m'
BGREEN='\033[1;32m'
NC='\033[0m'


if [[ $SDPATH == *"/run/media"* ]]; then
        notify-send "Sync started on $SDPATH" || echo " "
        echo -e "${BGREEN}###########################################################"
        echo -e "# Sync started on $SDPATH"
        echo -e "###########################################################${NC}\n"
        echo -e "${GREEN}### Sync started Documents --> $SDPATH...${NC}\n \n"
        rsync -au --inplace --progress /home/vincintosh/Documenti $SDPATH
        echo -e "\n${GREEN}### Sync started $SDPATH --> Documenti...${NC}\n"
        rsync -au --inplace --progress $SDPATH /home/vincintosh/Documenti
        sleep 1
        notify-send "$SDPATH sync completed!" || echo " "
        echo -e "${BGREEN}\ Sync on $SDPATH completed!${NC}"
        exit 0
else
        echo -e "${RED}Device $SDPATH not mounted or not backup drive. Sync aborted${NC}"
        exit 1
fi

Now, I know this might not be the most efficient way to write this script but my scripting knowledge is limited and, before improving the script, I wanted to check if rsync actually works.
Anyway, when I run the script and the second part starts (rsync from SD to my Documents folder), after some files are successfully transferred rsync gives an Input/Output error followed by a list of some file paths on the SD, each followe by "Transport endpoint is not connected (107)". Then one single file path followed by "failed verification -- update retained (will try again)." and it aborts with this last error

rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1189) [sender=3.1.3]

At this point the SD card is unusable and remains in an I/O error state: no files can be opened nor can it be browsed from the file manager, nor can be unmounted. This until I phisically eject it and insert it again into the SD card slot of my laptop and remount it (or have KDE automount it for me).

A couple of interesting things I noticed are:
- the error happens when it starts to transfer some .NEF files (Nikon RAW photos), but then all kind of files won't be transferred
- the SD card is formatted in an exfat filesystem because I need it to be fully writable on a Windows installation I have on one of my laptops and on Windows PCs at work
- Before this SD card solution, I tried mounting a folder on a USB stick connected to a Raspberry Pi through SSHFS and when I ran Rsync on it, and in this case the laptop keeps disconnecting and reconnecting to the WiFi router until I turn the router off and on again (and of course I get an I/O error on rsync again). This might be interesting because the problem maybe related to FUSE filesystems (?) But it seems strange anyway...

I'm confused, any suggestions are accepted and thanks for your time.

Last edited by Vincintosh (2020-01-14 17:31:02)

Offline

#2 2020-01-14 17:29:49

Vincintosh
Member
Registered: 2017-10-13
Posts: 18

Re: I/O error while rsyncing on an SD card

Alright guys, after a couple of hours of troubleshooting (zzz) I found the issue: the -a option of rsync doesn't like exfat filesystems, it's best to use SOME of the options included in -a (i.e. -vrltD ). It is also important to type that forward slash after the folder you want to sync files from, because this tells rsync you need the contents of the folder to be recoursively synced, otherwise it will copy the folder itself into the destination path and when you sync back this process happens again and again, in a never ending inception-style loop lol

#! /bin/bash

#this checks if the SD card is mounted and gathers path
SDPATH=$(lsblk | grep mmc | grep 'DocSD' | awk {'print $7'})

#colors
RED='\033[0;31m'
GREEN='\033[0;32m'
BRED='\033[1;31m'
BGREEN='\033[1;32m'
NC='\033[0m'


if [[ $SDPATH == *"/run/media"* ]]; then
        notify-send "Sync started on $SDPATH" || echo " "
        echo -e "${BGREEN}###########################################################"
        echo -e "# Sync started on $SDPATH"
        echo -e "###########################################################${NC}\n"
        echo -e "${GREEN}### Sync started Documents --> $SDPATH...${NC}\n \n"
        rsync -vrltD  --inplace --progress /home/vincintosh/Documenti/ $SDPATH
        echo -e "\n${GREEN}### Sync started $SDPATH --> Documenti...${NC}\n"
        rsync -vrltD  --inplace --progress $SDPATH/ /home/vincintosh/Documenti
        sleep 1
        notify-send "$SDPATH sync completed!" || echo " "
        echo -e "${BGREEN}\ Sync on $SDPATH completed!${NC}"
        exit 0
else
        echo -e "${RED}Device $SDPATH not mounted or not backup drive. Sync aborted${NC}"
        exit 1
fi

Issue solved, thread can be closed. Please excuse me if it may look like I posted too fast before doing  appropriate research, but believe me, I've spent already a couple of afternoons on this and could not figure out why it didn't want to work

Last edited by Vincintosh (2020-01-14 17:31:12)

Offline

#3 2020-01-14 19:02:01

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 4,645

Re: I/O error while rsyncing on an SD card

Vincintosh wrote:

Issue solved, thread can be closed.

You do this yourself by marking your thread [SOLVED] (edit the title of your first post).

How to Post


How to post. A sincere effort to use modest and proper language and grammar is a sign of respect toward the community.

Offline

Board footer

Powered by FluxBB