LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-28-2014, 04:33 AM   #1
AmirSI
LQ Newbie
 
Registered: Mar 2014
Posts: 13

Rep: Reputation: Disabled
Auto Sync


Hello,
on my Ubuntu server i have mounted folder from NAS-QNAP and one from SFTP.

NAS-QNAP folder in automounted in /etc/fstab using:

//10.0.0.0/vmware-bkp/Git-Server/ /home/administrator/mnt/QNAP-Git-Server/ cifs username=admin,password=admin 0 0

And for SFTP folder i added command in /etc/rc.local :

sshfs enerdat@backup.com:/backup ~/mnt/test/

I tryed to add SFTP also in /etc/fstab, but nothing didnt work.

Now i need this two folders to auto sync everyday at 2am.
I tryed to run basic command whit rsync, but for now nothing is working.

Last edited by AmirSI; 03-28-2014 at 06:15 AM.
 
Old 03-28-2014, 06:54 AM   #2
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
well sounds like you are on the right track with rsync, but we need more info. if you are unsuccessful at mounting the sftp share via fstab what else have you tried? have you looked into autofs? also keep in mind that if you can manually mount the sftp share you dont need to have it mounted for rsync to work as rsync will run over ssh connection just as sftp share does.

use code flags, post the exact output errors and the code you are using to attempt to get your rsync to run. also this is a job for cron.
 
Old 03-28-2014, 07:11 AM   #3
AmirSI
LQ Newbie
 
Registered: Mar 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Ok, i will take a look at autofs. I finally made rsync to start working, i added some additional properties.

Now it look like this:

rsync -pvzhriu --delete /home/administrator/mnt/QNAP-Git-Server/ /media/server/Git-Server/

Now i need some typ of schedule to run this command, ever day at 2am.
If possible as super user,
 
Old 03-28-2014, 07:34 AM   #4
AmirSI
LQ Newbie
 
Registered: Mar 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
Will it work, if i just add this line in "/etc/crontab".

00 03 * * * root rsync -pvzhriu --delete /home/administrator/mnt/QNAP-Git-Server/ /media/server/Git-Server/

If anyone have any better way to do this sync, please let me know...

Last edited by AmirSI; 03-28-2014 at 07:46 AM.
 
Old 03-29-2014, 11:59 AM   #5
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
always best to put it into a simple little script, put your path in your crontab, and run it from cron. see my first post.

you might also want to consider building in error checking and logging so that data can be verified it was transmitted and you can use the logging down the road if something happens for trouble shooting.
 
Old 03-31-2014, 02:26 AM   #6
AmirSI
LQ Newbie
 
Registered: Mar 2014
Posts: 13

Original Poster
Rep: Reputation: Disabled
I had problem over the weekend, its looks like that over some time, i lose connection to sftp.
So when schedule try to run my command, it just create new folders, becuse sftp is not mounted.
How can i mount this sftp, to stay connected?

If i add "-o reconnect", will this do the work:
sshfs user@backup.si:/backup /media/server/ -o reconnect

Last edited by AmirSI; 03-31-2014 at 03:50 AM.
 
Old 03-31-2014, 07:11 AM   #7
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
this is where the script will come in handy. create a bash script that verifies if the share is mounted, if not mount it, then perform the transfer via rsync. confirm the transfer then exit program.
 
  


Reply



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
RAID1: Urgent.. Two disks out of sync... how to get them back in sync? tkalfaoglu Linux - Server 1 10-18-2013 03:42 AM
LXer: BitTorrent Sync: Automatically sync files on your Linux Devices LXer Syndicated Linux News 0 10-04-2013 03:50 PM
USB pen drives not auto prompting or auto mounting on KDE3.5 (PCLOS) k.king Linux - General 1 03-17-2009 03:16 PM
Sync for Samsung Sync master Naphoon Linux - Hardware 1 10-16-2004 06:20 PM
SAMBA auto sync shares KaiserSoze860 Linux - Software 0 05-16-2004 01:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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