处理 rsync、dd 和快照的多次调用

处理 rsync、dd 和快照的多次调用

服务器经常会进行以下操作:对逻辑卷进行快照,然后将内容备份到远程备份服务器。有可能同时进行多个备份和传输。过多的 rsync 会话和挂载的快照卷会不会有问题?处理时如何优化服务器性能?

lvcreate -L10G -s -n snapshot /home/folderA 

dd if=/mnt/snapshot bs=1M | (ssh [email protected] of=/tmp/backups bs=1M)

rsync -avzh --rsh "ssh -l username" /mnt/snapshot 192.168.1.5:/tmp/backups/  

答案1

对这些进行某种锁定可能是最安全的,以便无论选择哪一个,一次只能运行一个实例,但如果不知道您(计划)运行它们的频率以及它们需要多长时间,就很难确定。

CentOS 有羊群(1)命令将会很有用。

[ “${FLOCKER}” != “$0” ] && exec env FLOCKER="$0" flock -en “$0” “$0” “$@” || :

          This is useful boilerplate code for shell scripts.  Put it at
          the top of the shell script you want to lock and it'll
          automatically lock itself on the first run.  If the env var
          $FLOCKER is not set to the shell script that is being run,
          then execute flock and grab an exclusive non-blocking lock
          (using the script itself as the lock file) before re-execing
          itself with the right arguments.  It also sets the FLOCKER env
          var to the right value so it doesn't run again.

相关内容