#!/bin/bash

定义源主机IP、用户名、密码和目标主机IP、用户名、密码

source_host='source_host_ip' source_user='source_host_user' source_password='source_host_password' target_host='target_host_ip' target_user='target_host_user' target_password='target_host_password'

定义源文件夹和目标文件夹

source_folder='/path/to/source/folder' target_folder='/path/to/target/folder'

使用lftp命令同步文件夹

lftp -u $source_user,$source_password $source_host <<EOF mirror -R $source_folder $target_folder EOF

将同步日志输出到文件

echo '[$(date)] Synced $source_folder to $target_folder' >> /var/log/sync.log

echo 'Sync completed.'

Linux 主机间 FTP 文件夹同步脚本

原文地址: https://www.cveoy.top/t/topic/nYTp 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录