如何使用rsync将目录移动到远程?
问题描述:
如何提出这个问题有点令人困惑。 我有一个命名为exec
文件夹,exec
文件夹内我有文件作为如何使用rsync将目录移动到远程?
node_modules
exec.js
hello.txt
package.json
AIM:我想用rsync将这个文件夹exec
移动到我的远程计算机。
在exec.js
我写的逻辑,以将文件夹移动到我的遥控器,( 在这之前我检查的rsync是否采取虚拟txt文件的工作,并使其移动到远程机器这是achieveable对我来说) 。
exec.js
console.log('1');
var exec = require('child_process').exec;
exec('node -v'+ '&& dir'+ '&& rsync -avz -e "ssh -o StrictHostKeyChecking=no\
-o UserKnownHostsFile=/dev/null" --progress\
hello.txt [email protected]:/home/ec2-user/exec',\ //how to include the folder exec in place of hello.txt, so that my whole folder moves to remote?
function (error, stdout, stderr) {
console.log('stdout', stdout);
if (error !== null) {
console.log('exec error: ', error);
}
});
答
找到出路这个问题,
'*' 将在地方hello.txt的一起工作。
console.log('1');
var exec = require('child_process').exec;
exec('node -v'+ '&& dir'+ '&& rsync -avz -e "ssh -o StrictHostKeyChecking=no\
-o UserKnownHostsFile=/dev/null" --progress\
* [email protected]:/home/ec2-user/exec',\ //how to include the folder exec in place of hello.txt, so that my whole folder moves to remote?
function (error, stdout, stderr) {
console.log('stdout', stdout);
if (error !== null) {
console.log('exec error: ', error);
}
});