Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop 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.
I am looking for a way to use RSYNC to copy all users' HOME directory to a second hard drive as part of my backup process.
Ideally, I would like to lock down the second hard drive so that only one specific user (that I will create and never log in under) can write to. Under these new permissions, how would I run rsync to sync the files to the second hard drive?
Simple: run the process AS the user on the local side, and use credentials for a local user on the remote side, and lock down the permissions so that only the users involved have access to the file space involved.
There are other possible solutions, but this one is easy, obvious, and requires no additional hoop jumping or special software.
A few more details as to how things are to be done, might be helpful.
Is the second drive:
part of the hardware of the machine with the user's HOME directories?
part of the hardware of a different machine, and to be accessed by something such as being NFS mounted on the machine with the user's HOME directories?
part of the hardware of a different machine, and to be accessed remotely without being mounted on the machine with the user's HOME directories?
Is the backup to be initiated:
manually?
or automatically at a particular time, by something such as cron, or in some other way in which you would expect it to operate without needing to manually enter a password?
Are the Users intended to have read access to the backups of their own files?
The second hard drive is in the same computer as the main hard drive (containing the users' HOME directories) Ideally, the script would be ran automatically at 2AM in the morning and would keep the same file permissions that exist on the main hard drive.
It might be helpful to explain the larger picture/project here. I want to have a way to backup my data locally. All data is from the users' home directory, as this is all I would care about if something would happen. Since I need something sooner than later, I decided to just put a second hard drive in my desktop computer and schedule an RSYNC event. I would also like to make two changes to the system: (1) Not allow any user (without root access) to mount a drive (2) All users (without root access) to only see the main hard drive.
My next step would be to build a barebone computer with all networking capabilities removed and eight hard drives with scheduled weekly backups (some how) going to each pair of hard drives.
For example, the first two hard drives would be for week 1, with the first hard drive of the first set receiving the RSYNC while the second hard drive would mirror the first one. Week 2 would do the same exact procedure except it would only touch the second set, leaving the other sets in tact.
If you plan to build a second machine anyway, why not build it on network and run BURP?
This way you get better backups, encrypted and with de-duplication at the block level, using the rsync libs for efficency, with compression and get FAR better use of those backup storage disks!
For a business I would recommend a separate back-end and backup network, but for home use you can even keep it on the same network. I do recommend running this BURP server in a different room. If your main machine catches fire and burns that room down, you want your backup machine away form the blaze (and fire hoses)!
The various commands can be put in a simple bash script. I'd suggest making sure that the rsync command you use does what you think it should - notice the comment about the /'s in the link.
There is a better than average man page on rsync here
(1) Not allow any user (without root access) to mount a drive (2) All users (without root access) to only see the main hard drive.
As I feel Habitual showed quite nicely, there doesn't necessarily have to be anything particularly tricky or inefficient about using rsync for backups.
Preventing Users other than root from mounting a drive should effectively just be a system configuration setting.
If by Users can only "see" the main hard drive, you mean they can't read or examine files on the backups, which they normally wouldn't be able to on the main drive, rsync can put the permissions of the original files, on the backup files; AFAIK with a number of the rsync implementations that have been done, Habitual's script would already do that.
I'd like to know more about rsync too. I know it's a somewhat n00b question, but even though I've been a UNIX power user and admin, I never really learned how to use it. I tried to run it over ssh and rsync seemed to only copy files from the local directory to the target directory, but not the other way around. Is that because I was just doing it on the command line not in daemon mode? or for some other reason?
I'd like to know more about rsync too. I know it's a somewhat n00b question, but even though I've been a UNIX power user and admin, I never really learned how to use it. I tried to run it over ssh and rsync seemed to only copy files from the local directory to the target directory, but not the other way around. Is that because I was just doing it on the command line not in daemon mode? or for some other reason?
Every question has the potential to sound like a n00b question until it is answered. Do not worry about that.
Rsync command line syntax includes a Source and a Target. In general, the Source files are only read, and all of the writing occurs at the Target. It is not a bidirectional sync by default. There are options to modify some things about its behavior, If you want to know more I suggest you examine the man pages, then with that information somewhat in mind seek out some how-to docs on the internet to clear up the concepts.
More advice for n00bs: Feel free to experiment with rsync command-line options, but work it out first on a small directory before you attempt a large backup. Here's an example from another thread, in which there was a question about how the rsync --compare-dest option works:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.