我有一个脚本将Amazon S3存储桶作为我的CentOS 6.5计算机上的挂载点附加
我正在尝试利用rsync将文件从2个位置复制到存储桶
代码:
#!/bin/bash
# SET THE BUCKET NAME HERE
S3_BUCKET="my-bucketname";
# SET THE MOUNT POINT HERE
MNT_POINT="/mnt/my-mountpoint";
# Create the mount point if it does not already exist, and set permissions on it
if [[ ! -e $MNT_POINT ]]; then
mkdir $MNT_POINT;
chmod -R 0777 $MNT_POINT;
fi;
# Mount the bucket
riofs -c ~/.config/riofs/riofs.conf.xml -o rw,allow_other,umask=2777,uid=1000,gid=1000 --cache-dir=/tmp/cache $S3_BUCKET $MNT_POINT;
mkdir $MNT_POINT/home;
mkdir $MNT_POINT/mysqlbak;
# Copy all "User" directories, except those owned by root
for filename in /home/* ; do
# Get the owner of $filename.
ACCT=$(stat -c '%U' "$filename");
# If the file is a directory NOT owned by root, run backup.
if [ -d "$filename" -a "$ACCT" != "root" ]; then
# Rsync to the mount
rsync -a /home/$filename $MNT_POINT/home;
fi;
done;
# Copy all mysql backups
for mysqlbak in /mysqlbak/* ; do
# Rsync to the mount
rsync -a /mysqlbak/$mysqlbak $MNT_POINT/mysqlbak;
done;
# No need to keep it mounted
umount $MNT_POINT;
正如您所看到的,我正在尝试保留/ mysqlbackup文件夹内容的备份,以及/ home的内容(减去附加到root帐户的任何内容)
问题是,当我在服务器上运行此脚本时,我收到以下错误:
rsync: change_dir "/home//home" failed: No such file or directory (2)
rsync error: some files/attrs were not transfered (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
和
rsync: change_dir "/mysqlbak//mysqlbak" failed: No such file or directory (2)
rsync error: some files/attrs were not transfered (see previous errors) (code 23) at main.c(1039) [sender=3.0.6]
我可以向你保证/ home和/ mysqlbak都存在。
如何解决此问题,以便正确同步到此挂载?
/ home和/ mysqlbak未在存储桶中创建
答案 0 :(得分:2)
替换
rsync -a /home/$filename $MNT_POINT/home;
通过
rsync -a $filename $MNT_POINT/home;
并替换
rsync -a /mysqlbak/$mysqlbak $MNT_POINT/mysqlbak;
通过
rsync -a $mysqlbak $MNT_POINT/mysqlbak;