Windows regularly backs up the SVN directory to Linux via rsync

Source: Internet
Author: User
Tags echo 7 rar svn touch win32 rsync

The general idea is:
First export the SVN directory under Windows to a folder (so there is no extra. SVN directory), then package the directory as a *.rar file via WinRAR, and then sync the packaged file to the Linux server via the rsync command.

Introduce the basic environment first.

The code is as follows Copy Code

#IP地址:
Windows 192.168.1.138
Linux 192.168.1.132

#windows下相关软件安装目录:

The code is as follows Copy Code
SVN installation directory D:\Program Files\svn-win32-1.6.16\bin\svn.exe
WinRAR installation directory C:\Program Files\winrar\winrar.exe
Rsync installation directory D:\Program Files\cwrsync\bin\rsync.exe
OK, let's get started.

1, Linux under the Rsync installation can refer to here:

The code is as follows Copy Code


http://www.linuxsir.org/main/?q=node/256

Ubuntu can be installed directly with the command:

The code is as follows Copy Code
sudo apt-get install rsync

2, configure Linux on the Rsync-server

  code is as follows copy code

#创建目录和文件
MKDIR/ETC/RSYNCD
touch/etc/rsyncd/rsyncd.conf
touch/etc/rsyncd/rsyncd.secrets
chmod 600 /etc/rsyncd/rsyncd.secrets
TOUCH/ETC/RSYNCD/RSYNCD.MOTD
#修改配置文件内容
# Detailed instructions see http: rsync.samba.org/ftp/rsync/rsyncd.conf.html
#/etc/rsyncd/rsyncd.conf content as follows
pid file =/var/run/rsyncd.pid
uid = root
gid = root
hosts allow=*
Read Only = no

[Snsgamebak]
Path =/home/backup/socialgame /
Auth users = root
Secrets file =/etc/rsyncd/rsyncd.secrets
#/etc/rsyncd/rsyncd.secrets contents are as follows
root:12345 6

3, Start Rsync-server

The code is as follows Copy Code
/usr/bin/rsync--daemon--config=/etc/rsyncd/rsyncd.conf
#检查一下
Ps-ef | grep rsync

4, the Rsync Software (cwrsync_4.1.0_installer.zip) under Windows can be downloaded here:

The code is as follows Copy Code

http://sourceforge.net/projects/sereds/files/cwRsync/4.1.0/

5, configure rsync on Windows

The code is as follows Copy Code
#修改配置文件内容
# E:/ggg/rsyncd.secrets content is as follows
123456

6, test all files and subdirectories in the e:/ttt/directory on Windows to the Linux server

The code is as follows Copy Code
D:
CD "Program files/cwrsync/bin/"
Rsync-r/cygdrive/e/ttt/root@192.168.1.132::snsgamebak--password-file=/cygdrive/e/ggg/rsyncd.secrets

Description

Because in the rsync command colon: has special meaning, so the above command in the E: disk is represented by/cygdrive/e.
The Snsgamebak in the command corresponds to [Snsgamebak] in the Linux/etc/rsyncd/rsyncd.conf
The above command synchronizes all files and subdirectories in the e:/ttt/directory to the/home/backup/socialgame/directory on the Linux server.
7, write the Bak_rsync.bat program,
The function of the implementation is to update the SVN directory (E:\www\game) first
It is then exported to the backup directory (E:\ggg\bak\20110608\), and the backup directory is automatically generated.
Then call winrar to compress the backup directory into a RAR file and delete the backup directory
Then rsync the RAR file to the Linux server
Finally delete the local backup RAR file and return to the home directory

The contents of the Bak_rsync.bat file are as follows

The code is as follows Copy Code

Start Backup @echo ======[]======
@echo off

Set svntool= "D:\Program Files\svn-win32-1.6.16\bin\svn.exe"
Set winrartool= "C:\Program Files\winrar\winrar.exe"
Set rsynctool= "D:\Program Files\cwrsync\bin\rsync.exe"

Set filename=bak_%date:~0,10%

@echo 1, update the SVN directory
%svntool% Update E:\www\game

@echo 2, find the SVN directory to the backup folder
%svntool% Export E:\www\game E:\ggg\bak\%filename%

@echo 3, check to see if there is a backup file with the same name, delete it if there is
CD bak
IF EXIST%filename%.rar del/f/s/q%filename%.rar

@echo 4, compress the backup folder into a backup file
%winrartool% m-r%filename%.rar%filename%\*

@echo 5, delete backup folder
RmDir%filename%/q

@echo 7, sync to Linux Server
%rsynctool%-r/cygdrive/e/ggg/bak/%filename%.rar Root@192.168.1.132::snsgamebak--password-file= /cygdrive/e/ggg/rsyncd.secrets

@echo 8, delete local backup files
Del%filename%.rar/q

@echo 6, return to the home directory
Cd..

8, add the Bak_rsync.bat to the task plan and execute it regularly.

P.S. In fact, there is a simpler way to install SVN directly on the 132 machine, directly checkout the svn-server under Windows.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.