How to exclude .cpan folder from rsync? - backup

I use rsync to backup the home directory (ext4) of my Ubuntu installation. I use the following command to copy files and folders to a remote server (ext4).
$ rsync -rt --delete --delete-excluded --links \
--exclude-from '/home/jjd/rsync-home-exclude.txt' \
/home/jjd/ server:/volume1/backup-home
I defined some folders and files which can be ignored for the backup:
$ cat /home/jjd/rsync-home-exclude.txt
/home/jjd/.thumbnails/
/home/jjd/Downloads/.org.chromium.Chromium*
/home/jjd/.cpan
.cache/
*.swp
*.lock
*.tmp
/home/jjd/.local/share/recently-used.*
.TrueCrypt/.show-request-queue
.dropbox/command_socket
.dropbox/iface_socket
*.sock%
Nevertheless, rsync still reports the following errors:
rsync: opendir "/home/jjd/.cpan/build/local-lib-1.008009-Xl6GGK/inc" failed: Permission denied (13)
rsync: opendir "/home/jjd/.cpan/build/local-lib-1.008009-Xl6GGK/lib" failed: Permission denied (13)
rsync: opendir "/home/jjd/.cpan/build/local-lib-1.008009-Xl6GGK/t" failed: Permission denied (13)
IO error encountered -- skipping file deletion
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1070) [sender=3.0.9]

Just remove /home/jjd from the exclude file. According to the rsync documentation, a leading slash does not apply to the root of the filesystem, but to the "root of the transfer".

Related

SSH failed: No such file or directory (2)

I try to copy files with rsync and i have checked multiple times that the address is correct but still i get feedback: no such directory. The code is:
rsync -azvrP -e ssh master_123#165.x.x.115:/applications/123/public_html/wp-content/uploads/2023/ /applications/321/public_html/wp-content/uploads/2023/
What could be the error?

SCP log file to server

Hello I am trying to SCP a log file to serve and I keep getting error
Warning: Identity file ids-east-1.pem not accessible: No such file or directory.
ec2-11.com: Permission denied (publickey).
lost connection
I have tried all the solutions presented earlier but can't seem to figure out what's wrong.
The key I am using is :
scp -r -i ids-east-1.pem ~/int/resources/tests/tasks/lib/testing.log ec2-user#11.com:/home/wn/shelf/wrDb/fractions
Just a reminder- I am able to get a log file from this server using :
scp -i ids-east-1.pem ec2-user#11.com:/home/wn/shelf/wrDb/fractions/chrono.log ~/Desktop/aws_chrono.log
If one command works, but the other gives you:
Warning: Identity file ids-east-1.pem not accessible: No such file or directory.
You are likely not running the commands from the same directory. Try specifying the key path fully (something like):
scp -i ~/.ssh/ids-east-1.pem ...

Why rsync fails with jenkins

When rsync is used with jenkins as Execute shell Command on CentOS 6.4, it fails:
[workspace] $ /bin/sh -xe /tmp/hudson3424899639384884888.sh
+ rsync -av /var/lib/jenkins/jobs/myjob/workspace/target/classes/ myuser#myserver.com:/home/myuser/test
rsync: Failed to exec ssh: Permission denied (13)
rsync error: error in IPC code (code 14) at pipe.c(84) [sender=3.0.6]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in IPC code (code 14) at io.c(600) [sender=3.0.6]
However, it works from the command line:
su jenkins
rsync -av /var/lib/jenkins/jobs/myjob/workspace/target/classes/ myuser#myserver.com:/home/myuser/test
sending incremental file list
sent 17875 bytes received 83 bytes 3990.67 bytes/sec
total size is 1981027 speedup is 110.31
What has to be done to make it work in jenkins as well?
The problem was with SElinux installed on CentOS, which for some reason were blocking ssh for rsync.
Here is a line from /var/log/messages which says the ssh was blocked:
Jun 12 13:45:59 myserver kernel: type=1400 audit(1434109559.911:33346): avc: denied { execute } for pid=11862 comm="rsync" name="ssh" dev=dm-1 ino=11931741 scontext=unconfined_u:system_r:rsync_t:s0 tcontext=system_u:object_r:ssh_exec_t:s0 tclass=file
For now we disabled SElinux on our server, proper solution would be to create custom policy module (1)
I had a similar problem.
In my case jenkins was not executing rsync with the expected user (jenkins) but with another (jboss in my case)
adding 'whoami' to the script and using ssh verbose:
rsync -e "ssh -v" .......
helped to find the problem.
Note, that when you change (add) jenkins user to some group, permission will apply after slave (agent) restart.

Centos 6.5, WHM : Rsync with Root disabled using ssh user from the Wheel Group

I'm trying to rsync files with my server, which has root login via ssh disabled. I'm trying to use one of the users I've created and added to to the wheel group. Usually - when I log in via ssh I run
su - root
then type the password and can run everything as root user, but not quite sure how to do it with rsync as I need to upload the files outside of the user directory.
When I run:
rsync -avz files/* sshwheeluser#ip_address:/home/newproject/public_html/
I get:
rsync: ERROR: cannot stat destination "/home/newproject/public_html/": Permission denied (13)
I have added the following to the /etc/sudoers file:
rsyncuser ALL= NOPASSWD:/usr/bin/rsync
plus I've un-commented:
%wheel ALL=(ALL) NOPASSWD: ALL
I've also tried to run the command with –rsync-path="sudo rsync" as suggested in some posts, but still no luck:
rsync -avz –rsync-path="sudo rsync" files/* sshwheeluser#ip_address:/home/newproject/public_html/
Next I tried to use it with additional -e "ssh":
rsync -avz -e "ssh" –rsync-path="sudo rsync" files/* sshwheeluser#ip_address:/home/newproject/public_html/
which changed the error message (looks like we're getting somewhere):
stdin: is not a tty
sudo: sorry, you must have a tty to run sudo
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at /SourceCache/rsync/rsync-40/rsync/io.c(452) [sender=2.6.9]
This post suggests that require_tty and tty_tickets should be disabled in sudoers, but I can't find these options in the /etc/sudoers file.
I've added (as recommended) Defaults !tty_tickets to the sudoers, but still the same message.
Any idea what else I need to do to make it work?
You should check Selinux logs, rsync is probably been blocked by Selinux.
You can also try to run:
semanage permissive -a rsync_t

rsync mkdir failed permission denied

I'm running PuTTy ssh on windows in the hope to copy a file from a remote server.
The command I used is below:
rsync -avz user#server:/home/user/imitate/tool /home/tool
But I received the error:
rsync: mkdir "/home/tool" failed: Permission denied (13)
rsync error: error in file IO (code 11) at main.c(605) [Receiver=3.0.9]
I'm totally new to this and I have no idea what is happening. So I logged into an account on a remote server using ssh, and want to copy files from that remote server to the laptop I'm using. What should I do?
you cannot write to /home/tool locally on your windows box. either run the command with more privileges or download to another directories where you have write permissions.