Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Mint 18.3 Cinnamon, Gallium, Ubuntu Armbian (headless), Arch (learning)
Posts: 138
Rep:
Rsync with root privileges command help...
I am starting to put together a command to backup my system. Right now I am having a hard time figuring out how to make rsync accomplish root privileges on the server.
Here's my setup and situation:
Linux Mint 18.3 Cinnamon
4.13.0-41 kernel
- My server doesn't allow root login (for security)
- I have my private keys active so no password needed to ssh
- I can't access the destination folder (on server) without root access. I don't want to change permissions. I have been using sudo -s for the very rare case that I need to access it through the CLI.
I am standing on other people's shoulders with how far I have gotten. I can't find much on the subject since 2012 so that tells me people must have found a better way to do it
Please know at this point I am just guessing, LOL! I started with a few lines from 2010 and I have been reading up and playing with the results.
If anyone could help me out, I would appreciate it. I know there is probably an easier way (something more GUI) but I enjoy learning the CLI so I KNOW what is going on and can have more control.
That command line is incorrect, and I do not really understand what was your plan with that.
To do the job I would rather suggest you to use rsync protocol (instead of ssh). You need to set up an rsyncd on that server and "share" the directory you want to rsync.
Also, the -z might slow things down or it might speed things up. However, for most binary data it will be irrelevant.
And mind the closing / on the directory paths. They are important.
And now I remember I had to do something with sudo and rsync in the past when I was using "dirvish" for backups, you may find the following useful reading:
Suggest looking at rsnapshot, which uses rsync but also provides a configuration file to define what to backup and when.
Here's a snippet from the rsnapshot log file that shows what happened this morning:
Code:
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded --exclude=/var/named --rsh=/usr/bin/ssh root@theremoteserver.com:/home/ /home/snapshots/daily.0/SCA/
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded --exclude=/var/named --rsh=/usr/bin/ssh root@theremoteserver.com:/etc/ /home/snapshots/daily.0/SCA/
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded --exclude=/var/named --rsh=/usr/bin/ssh root@theremoteserver.com:/usr/ /home/snapshots/daily.0/SCA/
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded --exclude=/var/named --rsh=/usr/bin/ssh root@theremoteserver.com:/var/ /home/snapshots/daily.0/SCA/
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded --exclude=/var/named --rsh=/usr/bin/ssh root@theremoteserver.com:/service/ /home/snapshots/daily.0/SCA/
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded --exclude=/var/named --rsh=/usr/bin/ssh root@theremoteserver.com:/root/ /home/snapshots/daily.0/SCA/
As you can see, this uses ssh, and the remote server has passwordless connection setup
Distribution: Mint 18.3 Cinnamon, Gallium, Ubuntu Armbian (headless), Arch (learning)
Posts: 138
Original Poster
Rep:
Sorry for not being able to keep up with this post today, I got busy with regular work.
Just to make it clear- I am trying to gain "root" access on my server. I have disabled root login and I have switched from using a password to using SSH keys. The goal is to be able to log in to my server, access a file folder that requires root access (sudo -s), and copy a backup from my desktop to said folder. I am pretty new to rsync, so please have patience with my lack of knowledge.
Pan64- Yes, I understand the command is incorrect. I pulled a similar command from online and was playing around with it to try and see how to manipulate it to work for what I am needing. I had been reading and trying things for a few hours before posting up with what I had left off with.
Turbocapitalist- Thank you! I will be reading the link after posting this....
TenTenths- Are you talking about the path to the rsync command itself or the path to the file I am trying to rsync to? Thank you, I will be reading about Dirvish about this post as well.
Kevinbenko- Thank you! Actually seeing how other people run commands helps me learn faster than starting at page one in the book and learning the history of the command inventors childhood. LOL! I am just better at hands on learning. My ADD kicks in about page 3 and I have to start practising what I am reading about.
scasey- Thank you Sean! I have it opened in another tab and will read up on rsnapshot after this post.
Habitual- Yes, I was scanning through this last night (and this morning).
Thank you all! The biggest problem I am running into is setting this up to save on a server that requires root access to even see the files. I know it can be done and I also realize that I am not the first to ever do this either
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.