ÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÊý¾Ýͬ²½
ÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõÄÊý¾Ýͬ²½
ÕªÒª£º¸ß¿ÉÓõÄÊý¾Ýͬ²½¹ØÓÚÆóÒµÀ´ËµÖÁ¹ØÖ÷Òª¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxϵͳÉÏÉèÖø߿ÉÓõÄÊý¾Ýͬ²½£¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£
СÐò£º
ÔÚµ±½ñµÄÐÅϢʱ´ú£¬Êý¾ÝÒѳÉΪÆóÒµÉúÑĺÍÉú³¤µÄÖ÷Òª×ÊÔ´¡£ÎªÁËÈ·±£Êý¾ÝµÄÇå¾²ºÍ¿ÉÓÃÐÔ£¬¸ß¿ÉÓõÄÊý¾Ýͬ²½¼Æ»®³ÉΪÁËÆóÒµµÄ±Ø±¸ÉèÖá£Linuxϵͳ×÷ΪÆÕ±éÓ¦ÓõIJÙ×÷ϵͳ֮һ£¬±¾ÎĽ«ÏÈÈÝÔõÑùÔÚlinuxÉÏÉèÖø߿ÉÓõÄÊý¾Ýͬ²½£¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£
Ò»¡¢È·ÈÏÐèÇó
ÔÚ×îÏÈÉèÖø߿ÉÓõÄÊý¾Ýͬ²½Ö®Ç°£¬Ê×ÏÈÐèҪȷÈÏÏÖʵÐèÇó¡£Ë¼Á¿ÒÔϼ¸¸ö·½Ã棺
Êý¾Ýͬ²½µÄƵÂÊ£ºÊÇʵʱͬ²½Õվɰ´ÆÚͬ²½£¿
Êý¾ÝµÄ¾ÞϸºÍÊýÄ¿£ºÈ·¶¨ÐèҪͬ²½µÄÊý¾ÝÁ¿£¬Ë¼Á¿´æ´¢ÐèÇó¡£
Êý¾Ýͬ²½µÄÄ¿µÄ£ºÊÇͬ²½µ½Ò»¸öÔ¶³ÌЧÀÍÆ÷£¬ÕÕ¾Éͬ²½µ½¶à¸öЧÀÍÆ÷£¿
ÈÝ´íÐÔºÍÔÖ±¸ÐÔ£ºË¼Á¿Êý¾Ýͬ²½Àú³ÌÖеÄÈÝ´íºÍÔÖ±¸»úÖÆ¡£
¶þ¡¢Ñ¡ÔñÊý¾Ýͬ²½¹¤¾ß
LinuxϵͳÉÏÓÐÐí´ó¶¼¾Ýͬ²½¹¤¾ß¿ÉÑ¡£¬Èçrsync¡¢rsnapshot¡¢LsyncdµÈ¡£Æ¾Ö¤ÏÖʵÐèÇóÑ¡ÔñÊʺϵŤ¾ß¡£ÏÂÃæÒÔrsyncΪÀýÏÈÈÝÔõÑùÉèÖø߿ÉÓõÄÊý¾Ýͬ²½¡£
×°ÖÃrsync£º
ÔÚԴЧÀÍÆ÷ºÍÄ¿µÄЧÀÍÆ÷ÉÏ×°ÖÃrsync£º
$ sudo apt-get install rsync
µÇ¼ºó¸´ÖÆ
ÉèÖÃrsyncЧÀÍÆ÷£º
ÔÚԴЧÀÍÆ÷ÉϽ¨ÉèrsyncÉèÖÃÎļþ/etc/rsyncd.conf£¬²¢±à¼ÈçÏÂÄÚÈÝ£º
uid = nobody gid = nobody max connections = 10 use chroot = yes read only = no timeout = 300 [backup] path = /data/backup comment = Backup directory auth users = backup_user secrets file = /etc/rsyncd.secrets
µÇ¼ºó¸´ÖÆ
ÉÏÊöÉèÖÃÖУ¬Ê¹ÓÃÁË/data/backup×÷ΪԴЧÀÍÆ÷µÄ±¸·ÝĿ¼£¬backup_userÊÇ»á¼û¸ÃĿ¼µÄÓû§Ãû¡£ÐèҪעÖصÄÊÇ£¬ÎªÁËÇå¾²Æð¼û£¬Ó¦È·±£/etc/rsyncd.secretsÎļþµÄȨÏÞΪֻ¶Á¡£
½¨ÉèrsyncÓû§£º
ÔÚԴЧÀÍÆ÷ÉϽ¨ÉèrsyncÓû§£¬Ö´ÐÐÒÔÏÂÏÂÁ
$ sudo adduser backup_user
µÇ¼ºó¸´ÖÆ
È»ºóΪ¸ÃÓû§ÉèÖÃÃÜÂ룺
$ sudo passwd backup_user
µÇ¼ºó¸´ÖÆ
½¨Éè/etc/rsyncd.secretsÎļþ£º
ÔÚԴЧÀÍÆ÷ÉϽ¨Éè/etc/rsyncd.secretsÎļþ£¬ÊäÈëÓû§ÃûºÍÃÜÂ룺
backup_user:password
µÇ¼ºó¸´ÖÆ
È»ºóÐÞ¸Ä/etc/rsyncd.secretsÎļþµÄȨÏÞ£º
$ sudo chmod 600 /etc/rsyncd.secrets
µÇ¼ºó¸´ÖÆ
Æô¶¯rsyncЧÀÍÆ÷£º
ÔÚԴЧÀÍÆ÷ÉÏÆô¶¯rsyncЧÀÍÆ÷£º
$ sudo systemctl start rsync
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ÉèÖÃrsync¿Í»§¶Ë£º
ÔÚÄ¿µÄЧÀÍÆ÷ÉϽ¨ÉèrsyncÉèÖÃÎļþ/etc/rsyncd.conf£¬±à¼ÈçÏÂÄÚÈÝ£º
uid = nobody gid = nobody max connections = 10 use chroot = yes read only = yes timeout = 300 [backup] path = /data/backup comment = Backup directory auth users = backup_user secrets file = /etc/rsyncd.secrets
µÇ¼ºó¸´ÖÆ
ͬÑùÐèÒª½¨Éè/etc/rsyncd.secretsÎļþºÍbackup_userÓû§£¬°ì·¨ÓëԴЧÀÍÆ÷Ïàͬ¡£
Æô¶¯rsync¿Í»§¶Ë£º
ÔÚÄ¿µÄЧÀÍÆ÷ÉÏÆô¶¯rsync¿Í»§¶Ë£º
$ sudo systemctl start rsync
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ͬ²½Êý¾Ý£º
ÔÚÄ¿µÄЧÀÍÆ÷ÉÏÖ´ÐÐÒÔÏÂÏÂÁ½«Ô´Ð§ÀÍÆ÷ÉϵÄÊý¾Ýͬ²½µ½Ä¿µÄЧÀÍÆ÷£º
$ rsync -avz backup_user@source_server::backup /data/
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬source_serverÊÇԴЧÀÍÆ÷µÄµØµã£¬backupÊÇrsyncЧÀÍÆ÷µÄÖ¸¶¨Ä£¿éÃû£¬/data/ÊÇÄ¿µÄЧÀÍÆ÷ÎüÊÕÊý¾ÝµÄĿ¼¡£
×ܽ᣺
¸ß¿ÉÓõÄÊý¾Ýͬ²½ÊÇÆóÒµ°ü¹ÜÊý¾ÝÇå¾²ºÍ¿ÉÓÃÐÔµÄÖ÷Òª»·½Ú¡£±¾ÎÄͨ¹ýrsync¹¤¾ßÌṩÁËÉèÖø߿ÉÓõÄÊý¾Ýͬ²½µÄÏêϸ°ì·¨£¬ÔÚLinuxϵͳÉÏʵÏÖÊý¾ÝµÄÇå¾²±¸·ÝºÍͬ²½¡£Ï£Íû±¾ÎĶÔÄúÔÚLinuxÉÏÉèÖø߿ÉÓõÄÊý¾Ýͬ²½ÓÐËù×ÊÖú¡£
²Î¿¼ÎÄÏ×£º
Rsync¹Ù·½ÍøÕ¾£ºhttps://rsync.samba.org/
RsyncÎĵµ£ºhttps://linux.die.net/man/1/rsync
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖø߿ÉÓõÄÊý¾Ýͬ²½µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡