LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How to Sync Files (https://www.linuxquestions.org/questions/slackware-14/how-to-sync-files-304483/)

jorasmi 03-21-2005 07:46 PM

How to Sync Files
 
Hi!,

I'm maintaining a company website that is hosted in a remote computer. The website accepts file submission(xls, doc, pdf, etc) via an online form. Files submitted are then strored in a directory. Every afternoon all files that are sent have to be downloaded via ftp and or web. Its a very time consuming process. I was thinking if there is a way to automatically synchronize na file from my remote server to my local server?

I'm running slackware linux as my local server and the 3rd party webserver is also running linux.

Thanks in advance!

DaHammer 03-21-2005 07:50 PM

You could use rsync and set it up as cron job to do every day or whenever.

jorasmi 03-21-2005 08:07 PM

Quote:

Originally posted by DaHammer
You could use rsync and set it up as cron job to do every day or whenever.
do i need to have rsync installed and running on my remote web server? i'm asking because i dont have complete control on the web server. presenty, i can only use ftp and the web control panel to download the files.

chbin 03-21-2005 08:59 PM

Yes the rsync service has to be running on the remote machine. If this is not possibe then use wget with the -r switch.

jorasmi 03-21-2005 09:16 PM

Quote:

Originally posted by chbin
Yes the rsync service has to be running on the remote machine. If this is not possibe then use wget with the -r switch.
PRECISELY WHAT I'M LOOKING FOR! I'LL READ THE DOCUMENTATION. THANKS!

chbin 03-21-2005 09:26 PM

one thing about that. wget with the -r switch is a "dumb" rsync. It will just grab everything every time you use it. rsync will just transferring things that changed. you can write a wget script checking for dates or something to get it to be more like rsync.

jorasmi 03-22-2005 12:09 AM

Quote:

Originally posted by chbin
one thing about that. wget with the -r switch is a "dumb" rsync. It will just grab everything every time you use it. rsync will just transferring things that changed. you can write a wget script checking for dates or something to get it to be more like rsync.
i'm already trying it. just like what you've said, its a little dumb but still very useful. i'm not really into shell scripting, can you help me with this or can you point me to a tutorial?

jorasmi 03-22-2005 01:45 AM

Quote:

Originally posted by chbin
one thing about that. wget with the -r switch is a "dumb" rsync. It will just grab everything every time you use it. rsync will just transferring things that changed. you can write a wget script checking for dates or something to get it to be more like rsync.
uup! when i was reading the documentation using -N will download the files that were updated in the server. I'm still trying it out.

DaHammer 03-22-2005 01:45 AM

You can do it with wget. Here's an example:
Code:

wget -m -np -nH --cut-dirs=4 "ftp://slackware.mirrors.tds.net/pub/slackware/slackware-10.1/isolinux/"
This will download everything in the "isolinux", as well as everything in any directory below it, to the directory you are in when you execute it. Here's how it breaks down.

-m - This turns on recursion, timestamping, & infinite recursion depth

-np - This prevents wget from ascending into the directories above the one you want

-nH - This cuts off the slackware.mirrors.tds.net

--cut-dirs=4 - This cuts off the pub/slackware/slackware-10.1/isolinux

Without the last 2 your files would be stored at "slackware.mirrors.tds.net/pub/slackware/slackware-10.1/isolinux" in under the directory you ran it from. See "man wget", as there are loads of options. If you want to run this daily automatically, then use cron, along with the -P option to wget. The -P option tells wget where to store the files, default is "." or current directory. To do that, run "crontab -e" from a command line and add something like this:
Code:

10 6 * * * wget -m -np -nH --cut-dirs=4 -P "/home/jorasmi/files" "ftp://slackware.mirrors.tds.net/pub/slackware/slackware-10.1/isolinux/"
That would run the command every day at 6:10 AM and email you the output. You add " 1> /dev/null" without quotes onto the end if you don't want to be emailed the output. Or you can use the -o option to wget to write the output to a log file instead and just email you errors. As you can see, 100s of ways to skin this cat. :) At any rate, the above will only download files that change and do it automatically so you don't have to touch it. If you want to use the HTTP protocol instead, then that's possible as well, but it introduces other issues like the index.html files and robots.txt if they apply. Anyway, play with it a bit to get it like you want it before you automate it.

jorasmi 03-22-2005 02:43 AM

Quote:

Originally posted by DaHammer
You can do it with wget. Here's an example:
Code:

wget -m -np -nH --cut-dirs=4 "ftp://slackware.mirrors.tds.net/pub/slackware/slackware-10.1/isolinux/"
This will download everything in the "isolinux", as well as everything in any directory below it, to the directory you are in when you execute it. Here's how it breaks down.

-m - This turns on recursion, timestamping, & infinite recursion depth

-np - This prevents wget from ascending into the directories above the one you want

-nH - This cuts off the slackware.mirrors.tds.net

--cut-dirs=4 - This cuts off the pub/slackware/slackware-10.1/isolinux

Without the last 2 your files would be stored at "slackware.mirrors.tds.net/pub/slackware/slackware-10.1/isolinux" in under the directory you ran it from. See "man wget", as there are loads of options. If you want to run this daily automatically, then use cron, along with the -P option to wget. The -P option tells wget where to store the files, default is "." or current directory. To do that, run "crontab -e" from a command line and add something like this:
Code:

10 6 * * * wget -m -np -nH --cut-dirs=4 -P "/home/jorasmi/files" "ftp://slackware.mirrors.tds.net/pub/slackware/slackware-10.1/isolinux/"
That would run the command every day at 6:10 AM and email you the output. You add " 1> /dev/null" without quotes onto the end if you don't want to be emailed the output. Or you can use the -o option to wget to write the output to a log file instead and just email you errors. As you can see, 100s of ways to skin this cat. :) At any rate, the above will only download files that change and do it automatically so you don't have to touch it. If you want to use the HTTP protocol instead, then that's possible as well, but it introduces other issues like the index.html files and robots.txt if they apply. Anyway, play with it a bit to get it like you want it before you automate it.

but how to download only the files that were updated?

DaHammer 03-22-2005 08:59 AM

What I posted will do just that.


All times are GMT -5. The time now is 12:03 PM.