bash - scp, inconsistency for file structure preservation -


  • my task: collect log files several servers.
  • server file structure: "/remote/path/dir/sub-dirs/files.log", same on servers. (all servers have same set of "sub-dirs", absence happen, , of course "files.log" names differ)
  • local file structure: "/local/path/logs"
  • after copy have "/local/path/logs/dir/sub-dirs/files.log"
  • method (in whlile loop servers): scp -r $servers:/remote/path/dir /local/path/logs
  • problem: reasons don't understand, first scp command ignores "dir" folder, "/local/path/logs/sub-dirs/files.log" following scp commands gives me intended "/local/path/logs/dir/sub-dirs/files.log"
  • why happening , how should fix/get around it?

thanks!

why happening [...]

in command scp -r path/to/source dest:

  • if dest doesn't exist, dest directory created, , path/to/source/* copied it. example if have path/to/source/x dest/x created.
  • if dest directory, dest/source created, , path/to/source/* copied it. example if have path/to/source/x dest/source/x created.

[...] , how should fix/get around it?

create dest in advance, example:

mkdir -p /local/path/logs scp -r $servers:/remote/path/dir /local/path/logs 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -