LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2020, 09:31 AM   #1
coderlen
Member
 
Registered: May 2018
Location: Greenwood, IN
Distribution: antiX
Posts: 151

Rep: Reputation: 17
Cannot get rsync script to backup files to USB


I have an rsync script which I use to backup my files to USB. Here is what the script looks like:

Code:
len@len-satellitee45ta:~/Backup$ cat rsyncDriveFUSBBackup2.sh 
rsync -avtu --modify-window=2 --exclude={'*.iso','Downloads','Desktop'} /home/len/* "/media/len/DRIVE F"
rsync -avtu --modify-window=2 /home/len/Documents "/media/len/DRIVE F"
When I execute this script, this is the error message:

Code:
len@len-satellitee45ta:~/Backup$ ./rsyncDriveFUSBBackup2.sh 
sending incremental file list
rsync: [Receiver] mkdir "/media/len/DRIVE F" failed: Permission denied (13)
rsync error: error in file IO (code 11) at main.c(758) [Receiver=3.2.2]
sending incremental file list
rsync: [generator] recv_generator: mkdir "/media/len/DRIVE F" failed: Permission denied (13)
*** Skipping any contents from this failed directory ***
Documents/

sent 71 bytes  received 174 bytes  490.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1287) [sender=3.2.2]
Here is the lsblk output:

Code:
len@len-satellitee45ta:~/Backup$ lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0     7:0    0    55M  1 loop /snap/core18/1880
loop1     7:1    0 309.8M  1 loop /snap/flightgear/36
loop2     7:2    0  29.9M  1 loop /snap/snapd/8542
loop3     7:3    0  55.3M  1 loop /snap/core18/1885
sda       8:0    0 931.5G  0 disk 
├─sda1    8:1    0   450M  0 part 
├─sda2    8:2    0   100M  0 part 
├─sda3    8:3    0    16M  0 part 
├─sda4    8:4    0 465.5G  0 part 
├─sda5    8:5    0   570M  0 part 
├─sda6    8:6    0     1G  0 part 
├─sda7    8:7    0  48.8G  0 part /media/len/rootantiX19
├─sda8    8:8    0   9.3G  0 part [SWAP]
├─sda9    8:9    0  57.5G  0 part /
├─sda10   8:10   0   1.1G  0 part 
├─sda11   8:11   0  53.7G  0 part 
├─sda12   8:12   0   4.2G  0 part 
└─sda13   8:13   0  46.6G  0 part 
sdb       8:16   0  29.8G  0 disk 
sdc       8:32   1  29.8G  0 disk 
└─sdc1    8:33   1  29.8G  0 part
Attached is the screenshot of the file manager listing of DRIVE F.

I am operating in SparkyLinux. Screenshot also attached.

I cannot imagine what I am doing wrong. But surely you all can help. Thanks.
Attached Thumbnails
Click image for larger version

Name:	gscreenshot_2020-08-09-102515.png
Views:	21
Size:	82.5 KB
ID:	33818   Click image for larger version

Name:	gscreenshot_2020-08-09-102917.png
Views:	16
Size:	66.8 KB
ID:	33819  
 
Old 08-09-2020, 09:45 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
It's very simple: The user account that attempts to copy to the DRIVE F directory doesn't have write permissions there.

By the way, the lsblk output shows two devices that might be 32GB drives (sdb and sdc), but they don't seem to be mounted. Which seems to conflict with the filemanager.

Find out if this drive is mounted at all, and if yes what are the mount options (the mount command is sufficient, though it outputs a lot of irrelevant lines).
 
1 members found this post helpful.
Old 08-09-2020, 10:03 AM   #3
coderlen
Member
 
Registered: May 2018
Location: Greenwood, IN
Distribution: antiX
Posts: 151

Original Poster
Rep: Reputation: 17
Thanks, berndbausch. I executed the mount command. Here is the relevant output:

Code:
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=394528k,nr_inodes=98632,mode=700,uid=1000,gid=1000)
/dev/sdc1 on /media/len/DRIVE F type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)
So it appears that DRIVE F is indeed mounted.
 
Old 08-09-2020, 11:41 AM   #4
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
I agree with berndbausch, the lsblk seems to show no /media/len/DRIVE F. According to the rsync output your user does not have necessary permissions.

Try looking in /proc/mounts to see if /dev/sdc1 is, indeed, mounted where you think it is. If so, run an ls -l on /media/len/DRIVE F and see what the permissions are. If that doesn't show the problem, then unmount, disconnect and remount. See if that solves it. The problem, according to rsync is
Code:
rsync: [Receiver] mkdir "/media/len/DRIVE F" failed: Permission denied (13)
Until you solve the apparent permissions problem on the receiver rsync isn't going to do a thing.

By the way, the -t option is already part of the -a option so is unnecessary (see the man page) and should be omitted.
 
1 members found this post helpful.
Old 08-09-2020, 01:57 PM   #5
coderlen
Member
 
Registered: May 2018
Location: Greenwood, IN
Distribution: antiX
Posts: 151

Original Poster
Rep: Reputation: 17
OK! I'm rolling along with all your help. Thanks so much.

@berndbausch: Your comment on user accounts and permissions got me to thinking: I wonder if I should put "sudo" in front of my script command? And that did the trick! It started backing up my files, and writing to DRIVE F.

However, for some reason most of the output, backed up files were protected, and I couldn't look at them. It turns out that they only had privileges for the root user. I'm the only user, so that's OK. I just issued a chmod +777 on all the files, and backed them up again.

I did have some other problems, not related to my script, as I was running out of room on my hard disk. I had to shrink and grow partitions with Gparted to get things rolling again.

@agillator: Thanks for the suggestions on the -t flag. I didn't know that.
Here is the pertinent area of /proc/mounts, showing that DRIVE F is mounted:

Code:
sunrpc /run/rpc_pipefs rpc_pipefs rw,relatime 0 0
/dev/loop3 /snap/core18/1885 squashfs ro,nodev,relatime 0 0
/dev/loop0 /snap/core18/1880 squashfs ro,nodev,relatime 0 0
/dev/loop2 /snap/snapd/8542 squashfs ro,nodev,relatime 0 0
/dev/loop1 /snap/flightgear/36 squashfs ro,nodev,relatime 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=394528k,nr_inodes=98632,mode=700,uid=1000,gid=1000 0 0
/dev/sdc1 /media/len/DRIVE\040F1 vfat rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro 0 0
I'm not sure why I need to run my script as root in order to get it to work, but that's something I'm willing to live with. This is the first time I've run the script on SparkyLinux. The other distros were Ubuntu and antiX, where it performed flawlessly.

Thanks so much for your quick response, and for the wisdom you offered me. You guys are the best!
 
Old 08-09-2020, 04:07 PM   #6
agillator
Member
 
Registered: Aug 2016
Distribution: Mint 19.1
Posts: 419

Rep: Reputation: Disabled
The issue is how your system is mounting your partition. Obviously it is mounting it with root as the owner therefore to create a directory or to write to the directory you need to be root therefore using sudo. If you manually change the owner and/or the permissions of the partition that may change. Experiment and see what YOUR system does when you unmount and mount the partition under different conditions.
 
Old 08-09-2020, 08:20 PM   #7
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
You marked it as solved, but there are still a few bits you can check if you want to fully understand what's going on.
Quote:
Originally Posted by coderlen View Post
Code:
/dev/sdc1 /media/len/DRIVE\040F1 vfat rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro 0 0
Am I missing something, or is it mounted at "/media/len/DRIVE F1", instead of "/media/len/DRIVE F"?

In case the mount point is not at issue here, I would check file and directory ownership with ls -l "/media/len/DRIVE F", and I would check if my user's ID is indeed 1000.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remote Backup script needed | backup every 1-2 seconds (Online/Hot backup) reda Linux - Newbie 4 04-20-2019 05:02 PM
LXer: Rsync Backup for Windows, Linux Knoppix, and Other Smart Technologies in Handy Backup by Novos LXer Syndicated Linux News 0 12-24-2011 11:43 AM
LXer: Backup with rsync and rsync.net LXer Syndicated Linux News 0 09-14-2010 04:20 PM
Using RSync to backup a secondary off-site backup server pezdspencer Linux - Software 4 06-29-2007 03:40 PM
Using rsync to backup data. Best way to backup folders? Micro420 Linux - General 2 11-23-2006 01:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration