Programmatically syncing with remote servers

My application generates text files that need to be synced with remote servers, which may be windows or linux. Sync has to happen without user’s intervention.

I tried with rsync but windows doesn’t come with rsync by default. Also it is not possible to supply password in the command line for rsync.

Currently I’m going with ftp. But that seems like an inefficient way.

Is there a way to rsync without user intervention? What are the ways to sync with a remote server programmatically? App is on nodejs.

4

Rather than using FTP which is insecure (compared to SFTP) and takes a lot of time and effort (relatively) I suggest you use SSH to upload the files to the remote server through SCP with Cron jobs (if this is a routine operation), or by adding an alias in your ~/.bash_profile for something like push text-files.

Because you’ve said this app runs with Node you can use something called exec to run commands from the script. For example you could say something like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>exec = require('child_process').exec;
exec('scp -r /path/to/the/files server:/path/they/should/upload/to');
</code>
<code>exec = require('child_process').exec; exec('scp -r /path/to/the/files server:/path/they/should/upload/to'); </code>
exec = require('child_process').exec;

exec('scp -r /path/to/the/files server:/path/they/should/upload/to');

Here’s a great article on setting up SSH with a Unix-based server if you’re unfamiliar: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys–2

You could also write jobs in your app with something like node-schedule or another job package. This approach means you can skip writing Cron jobs on the server. The Rails docs are completely unrelated to Node, but the introduction will give you an idea as to what jobs are and what they do: http://edgeguides.rubyonrails.org/active_job_basics.html

I think you should accomplish two tasks:

  1. watch source filesystem for change. This could be done by either cron job (task scheduler for windows) to check for changes, FTP watcher that checks changes in FTP server. I am sure there are other options too.
  2. You have to copy source files to target servers. This you can achieve in many ways trough ftp or ssh or even upload files through http.

Your best setup depends on what is already installed there on servers or what is easier for you to set up. Also do you need to sync back if files have changes in remote servers.

1

Synching entire files has the tendency to create more traffic than you want. It may be a better option to do this on a finer-grained level, using your own RPC service.

For example, you could have a look at Apache Thrift. It basically allows you to create a remote service to do next to anything what you want. It works cross-language, cross-platform out of the box, designed to be efficient and based on a very simple IDL.

While creating your own service may involve some work, you are no longer bound to transferring entire files (but you can of course do that as well), you will also be able to extend the service in the future easily.


If you still want to exchange whole files, consider compressing them beforehand, and using services like dropbox, or the like. Depending on the “disclosure-level” of your data, you may additionally want to encrypt them during transfer.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Programmatically syncing with remote servers

My application generates text files that need to be synced with remote servers, which may be windows or linux. Sync has to happen without user’s intervention.

I tried with rsync but windows doesn’t come with rsync by default. Also it is not possible to supply password in the command line for rsync.

Currently I’m going with ftp. But that seems like an inefficient way.

Is there a way to rsync without user intervention? What are the ways to sync with a remote server programmatically? App is on nodejs.

4

Rather than using FTP which is insecure (compared to SFTP) and takes a lot of time and effort (relatively) I suggest you use SSH to upload the files to the remote server through SCP with Cron jobs (if this is a routine operation), or by adding an alias in your ~/.bash_profile for something like push text-files.

Because you’ve said this app runs with Node you can use something called exec to run commands from the script. For example you could say something like this:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>exec = require('child_process').exec;
exec('scp -r /path/to/the/files server:/path/they/should/upload/to');
</code>
<code>exec = require('child_process').exec; exec('scp -r /path/to/the/files server:/path/they/should/upload/to'); </code>
exec = require('child_process').exec;

exec('scp -r /path/to/the/files server:/path/they/should/upload/to');

Here’s a great article on setting up SSH with a Unix-based server if you’re unfamiliar: https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys–2

You could also write jobs in your app with something like node-schedule or another job package. This approach means you can skip writing Cron jobs on the server. The Rails docs are completely unrelated to Node, but the introduction will give you an idea as to what jobs are and what they do: http://edgeguides.rubyonrails.org/active_job_basics.html

I think you should accomplish two tasks:

  1. watch source filesystem for change. This could be done by either cron job (task scheduler for windows) to check for changes, FTP watcher that checks changes in FTP server. I am sure there are other options too.
  2. You have to copy source files to target servers. This you can achieve in many ways trough ftp or ssh or even upload files through http.

Your best setup depends on what is already installed there on servers or what is easier for you to set up. Also do you need to sync back if files have changes in remote servers.

1

Synching entire files has the tendency to create more traffic than you want. It may be a better option to do this on a finer-grained level, using your own RPC service.

For example, you could have a look at Apache Thrift. It basically allows you to create a remote service to do next to anything what you want. It works cross-language, cross-platform out of the box, designed to be efficient and based on a very simple IDL.

While creating your own service may involve some work, you are no longer bound to transferring entire files (but you can of course do that as well), you will also be able to extend the service in the future easily.


If you still want to exchange whole files, consider compressing them beforehand, and using services like dropbox, or the like. Depending on the “disclosure-level” of your data, you may additionally want to encrypt them during transfer.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật