LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 05-24-2017, 03:46 PM   #1
mikedelo
Member
 
Registered: Mar 2004
Location: Staten Island, NY
Distribution: MX Linux
Posts: 63

Rep: Reputation: 0
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
 
Old 05-24-2017, 06:52 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687
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.
 
1 members found this post helpful.
Old 05-24-2017, 07:19 PM   #3
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
Hi mikedelo:

A few more details as to how things are to be done, might be helpful.

Is the second drive:
  1. part of the hardware of the machine with the user's HOME directories?
  2. 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?
  3. 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:
  1. manually?
  2. 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?
 
1 members found this post helpful.
Old 05-25-2017, 12:10 PM   #4
mikedelo
Member
 
Registered: Mar 2004
Location: Staten Island, NY
Distribution: MX Linux
Posts: 63

Original Poster
Rep: Reputation: 0
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
 
Old 05-25-2017, 03:21 PM   #5
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687
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)!
 
1 members found this post helpful.
Old 05-27-2017, 11:47 AM   #6
ajohn
Member
 
Registered: Jun 2011
Location: UK
Distribution: OpenSuse Leap
Posts: 122

Rep: Reputation: Disabled
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
-
 
1 members found this post helpful.
Old 06-01-2017, 10:37 AM   #7
mikedelo
Member
 
Registered: Mar 2004
Location: Staten Island, NY
Distribution: MX Linux
Posts: 63

Original Poster
Rep: Reputation: 0
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.
 
Old 06-01-2017, 11:39 AM   #8
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by mikedelo View Post
Any thoughts/feedback on just keeping it simple with an external hard drive and a pelican case?
Hey there Mike:

simple.sh / 700
Code:
#!/bin/bash
cd $HOME ; sync
/usr/bin/udisksctl mount -b /dev/sdc1 /media/jj/external  > /dev/null 2>&1
/usr/bin/ionice -c 3 /usr/bin/rsync -azv  . /media/jj/external/LM17/ --delete
#EOF
I am guessing you know all the pieces, parts for your "model"?

John
 
1 members found this post helpful.
Old 06-01-2017, 02:41 PM   #9
rigor
Member
 
Registered: Sep 2003
Location: 19th moon ................. ................Planet Covid ................Another Galaxy;............. ................Not Yours
Posts: 705

Rep: Reputation: Disabled
Quote:
Originally Posted by mikedelo View Post
(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.
 
1 members found this post helpful.
Old 06-01-2017, 06:17 PM   #10
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143
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?
 
1 members found this post helpful.
Old 06-01-2017, 07:45 PM   #11
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687Reputation: 2687
Quote:
Originally Posted by Laserbeak View Post
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.
 
2 members found this post helpful.
Old 06-01-2017, 09:02 PM   #12
Beryllos
Member
 
Registered: Apr 2013
Location: Massachusetts
Distribution: Debian
Posts: 529

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
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/#post5706894
We 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.
 
1 members found this post helpful.
Old 06-02-2017, 05:45 AM   #13
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Simple, Secure Backups for Linux with rsync may help.
 
1 members found this post helpful.
Old 06-12-2017, 08:29 AM   #14
mikedelo
Member
 
Registered: Mar 2004
Location: Staten Island, NY
Distribution: MX Linux
Posts: 63

Original Poster
Rep: Reputation: 0
Thank you all for your input and help!!!
 
Old 06-12-2017, 09:02 AM   #15
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Is is working out for you Mike?
 
  


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
[SOLVED] Rsync script problem RayLui20 Linux - Newbie 5 04-30-2015 11:31 AM
Need someone to look at rsync script JosephS Linux - Software 1 04-26-2015 05:50 PM
rsync backup script help henryyy Linux - Newbie 7 03-05-2013 02:31 PM
Rsync script help lleb Linux - Software 17 11-18-2011 03:30 PM
rsync script twantrd Programming 2 01-06-2005 05:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 02:47 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