RSYNC Script
Hello:
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? Mike |
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. |
Hi mikedelo:
A few more details as to how things are to be done, might be helpful. Is the second drive:
Is the backup to be initiated:
|
Thank you for your replies!
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. Thank you!!!!!!! Mike |
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)! |
This link might help the OP.
http://www.mikerubel.org/computers/rsync_snapshots/ 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 https://linux.die.net/man/1/rsync John - |
Any thoughts/feedback on just keeping it simple with an external hard drive and a pelican case? I can do weekly backups to two hard drives.
|
Quote:
simple.sh / 700 Code:
#!/bin/bash John |
Quote:
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?
|
Quote:
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:
http://www.linuxquestions.org/questi...6/#post5706894We created three local directories containing only two small files, did rsync, and inspected the result. That's what I mean by a small-scale test. |
|
Thank you all for your input and help!!!
|
Is is working out for you Mike?
|
All times are GMT -5. The time now is 02:29 AM. |