Created
February 28, 2020 13:25
-
-
Save encoreshao/7b0a960ebb5d74c8eefda8ffd5a83382 to your computer and use it in GitHub Desktop.
[Ruby] - Download the config files from the server and upload it to another server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # | |
| # Download the configuration file from the server and upload it to another server | |
| # | |
| # How to run it | |
| # | |
| # ruby sync-files.rb source_server target_server config_folder | |
| require 'fileutils' | |
| source_server = ARGV[0] | |
| local_folder = "#{source_server}-configs" | |
| target_server = ARGV[1] | |
| dest_dir = ARGV[2] | |
| FileUtils.mkdir_p local_folder | |
| system("scp -r #{source_server}:#{dest_dir}/* #{local_folder}") | |
| system("scp -r #{local_folder}/* #{target_server}:#{dest_dir}") | |
| FileUtils.rm_r local_folder | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment