Install and configure the SVN server in Linux-backup-recovery-scheduled tasks

Source: Internet
Author: User
Tags svn client tortoisesvn

Install and configure the SVN server in Linux-backup-recovery-scheduled tasks

Introduction:
SVN is short for Subversion. It is an open-source version control system. Compared with RCS and CVS, it adopts a branch management system. Its design goal is to replace CVS. Many version control services on the Internet have been migrated from CVS to Subversion.
Running Mode
Svn servers can run in two ways: independent servers and apache. The two methods have their own advantages and disadvantages. You can choose one of them.

I. Install svn

# yum install subversion-1.6.11-7.el5_6.4 mysql-server httpd mod_dav_svn mod_perl sendmail wget gcc-c++ make unzip perl* ntsysv vim-enhanced
Subversion-1.6.11-7.el5_6.4 (SVN server, Version) mysql-server (for codestriker) httpd mod_dav_svn mod_perl (for managing SVN servers in WEB mode) sendmail (for configuring user mail reminders after code submission) wget gcc-c ++ make unzip perl * (Required Software Package) ntsysv vim-enhanced (optional)
Description of the software package

Ii. basic configuration

1. Create a directory to store all SVN files.

# mkdir /data/svn# cd /data/

2. Create a version Repository

# svnadmin create /data/svn/project

3. initialize the directory in the version repository.

# Mkdir project/server project/client project/test // create a temporary directory. The directory is the data directory uploaded by developers # svn import project file: /// data/svn/project-m "initialization" # rm-rf project // Delete the created project file because it has been initialized to the svn version Library

4. Add a user

# vim /data/svn/project/conf/passwd
[Users] # harry = harryssecret # sally = sallyssecretadmin = 123456 // The admin password for the account is 123456 (the SVN account password is in plaintext and does not support the http ciphertext password, which will be explained below)

5. Modify the User Access Policy

# Vim/data/svn/project/conf/authz // record the user's access policy. The following is a reference:
[Groups] [/] admin = rw * = // * = indicates that no one except the user group with the preceding permissions is allowed to access this directory. This is very important and must be added!

6. Modify the svnserve. conf file and specify the password and policy file.

# vim svnserve.conf
[general]anon-access = noneauth-access = writepassword-db = /data/svn/project/conf/passwdauthz-db = /data/svn/project/conf/authz

7. Start the server

# svnserve -d -r /data/svn

Note: If the svn configuration is modified, restart the svn Service as follows:

# Ps-aux | grep svnserve # kill-9 ID # svnserve-d-r/data/svn

8. Test server (currently cannot pass web Testing)

# svn co svn://192.168.5.10/project
 
Authentication realm: <svn: // 192.168.5.10: 3690> d72f34c5-d386-4d19-bc8b-9e5192737eeePassword for 'root': // press ENTER Authentication realm: <svn: // 192.168.5.10: 3690> d72f34c5-d386-4d19-bc8b-9e5192737eeeUsername: admin // Password for 'admin': // Password set in passwd ------------------------------------------------------------------------------- ATTENTION! Your password for authentication realm: <svn: // 192.168.5.10: 3690> d72f34c5-d386-4d19-bc8b-9e5192737eeecan only be stored to disk unencrypted! You are advised to configureyour system so that Subversion can store passwords encrypted, ifpossible. see the documentation for details. you can avoid future appearances of this warning by setting the valueof the 'store-plaintext-password' option to either 'yes' or 'no' in '/root /. subversion/servers '. ----------------------------------------------------------------------- Store password unencrypted (Yes/no )? YesA project/testA project/serverA project/clientChecked out revision 1.
Login process

3. Configure http support for the svn server. You can start the httpd test.

1. Set apache's permission to access svn. Otherwise, apache does not have the permission to read data under svn.

# chown -R apache:apache /data/svn/

The SVN server password should be converted to the format supported by HTTP because the SVN server password is in plain text and not supported by the HTTP server.

2. Create a SVN account password that supports apache

# Touch passwd # htpasswd-c/data/passwd admin // create a user admin and set the password for it # cat passwd>/data/svn/project/conf/passwd
# Vim/data/svn/project/conf/passwd // comment on the admin plaintext account
#admin = admin

3. Add the following content to the apache configuration file to support the SVN service.

# vim /etc/httpd/conf/httpd.conf
 
<Location /project>DAV svnSVNPath /data/svn/project/AuthType BasicAuthName "svn for project"AuthUserFile /data/svn/project/conf/passwdAuthzSVNAccessFile /data/svn/project/conf/authzSatisfy allRequire valid-user</Location>
Restart svn and httpd services
# Ps-ef | grep svnserve
# Kill-9 3994
# Svnserve-d-r/data/svn
# Service httpd restart

4. Client Test

In this way, the svn client or browser of Windows is used for testing.

Browser test: http: // 192.168.5.10/project

Windows client test:

Install TortoiseSVN -----> right-click on the desktop -----> TortoiseSVN -----> Version library browser (R) -----> http: // 192.168.5.10/project -----> account password -----> OK

Note: Enter the account or password (the password is in non-plaintext format supported by http)

========================================================== ========================================================== ========================================================== ========================================================== ========================================================== ==========================================
========================================================== ========================================================== ========================================================== ========================================================== ========================================================== ==========================================

4. add or delete a version Library

Stop httpd, add a plaintext user to passwd, and set authz permissions.

# service httpd stopStopping httpd:                                            [  OK  ]# vim /data/svn/project/conf/passwd ::[users]# harry = harryssecret# sally = sallyssecret#admin = 123456test = testadmin:uyvcrbGbdBPuk::# vim /data/svn/project/conf/authz ::[groups][/]admin = rwtest = rw* =::# ps -ef |grep svnroot      4032     1  0 15:14 ?        00:00:00 svnserve -d -r /data/svnroot     25723  3556  0 16:35 pts/1    00:00:00 grep svn# kill -9 4032# svnserve -d -r /data/svn# svn ls svn://192.168.5.10/projectAuthentication realm: <svn://192.168.5.10:3690> d72f34c5-d386-4d19-bc8b-9e5192737eeePassword for 'admin': Authentication realm: <svn://192.168.5.10:3690> d72f34c5-d386-4d19-bc8b-9e5192737eeeUsername: testPassword for 'test': -----------------------------------------------------------------------ATTENTION!  Your password for authentication realm:   <svn://192.168.5.10:3690> d72f34c5-d386-4d19-bc8b-9e5192737eeecan only be stored to disk unencrypted!  You are advised to configureyour system so that Subversion can store passwords encrypted, ifpossible.  See the documentation for details.You can avoid future appearances of this warning by setting the valueof the 'store-plaintext-passwords' option to either 'yes' or 'no' in'/root/.subversion/servers'.-----------------------------------------------------------------------Store password unencrypted (yes/no)? yesclient/server/test/# svn delete svn://192.168.5.10/progect/client -m "delete"svn: No repository found in 'svn://192.168.5.10/progect/client'# svn delete svn://192.168.5.10/project/client -m "delete"Committed revision 2.# svn delete svn://192.168.5.10/project/server -m "delete"Committed revision 3.# svn delete svn://192.168.5.10/project/test -m "delete"Committed revision 4.# svn mkdir -m "UP" svn://192.168.5.10/project/unionCommitted revision 5.# svn mkdir -m "UP" svn://192.168.5.10/project/wangyiCommitted revision 6.# vim /data/svn/project/conf/passwd [users]# harry = harryssecret# sally = sallyssecret#admin = 123456test = testadmin:uyvcrbGbdBPuk# ps -ef |grep svnroot     25725     1  0 16:35 ?        00:00:00 svnserve -d -r /data/svnroot     25759  3556  0 16:40 pts/1    00:00:00 grep svn# kill -9 25725# svnserve -d -r /data/svn# service httpd startStarting httpd:                                            [  OK  ]
For more information, see

Files uploaded to the file directory of the svn version library are backup files of other servers.

# Export LANG = "zh_CN.GB2312" // set the variable when the file name is in Chinese # svn import/data/file: /// data/svn/project/file -- message "init" # svn import/data/file/svn: /// data/svn/project/file -- message "init" // The two commands are the same

V. SVN backup and restoration (two backup methods)

1. hotcopy backup mode: # svnadmin hotcopy/data/svn/project/data/bakup/'date +/% y % m % D'/-- clean-logs // use svnadmin for overall backup/data/svn /project to the/data/bakup/directory and name it by time 2. dump backup mode: # svnadmin dump/data/svn/project>/data/beifen/'date +/% Y % m % d '. bak // We recommend this method for backup. The following simulation uses the dump method.

6. Simulate server crash (recover to the new server when there is a backup file)

# rm -rf /data/svn/*# ps -ef |grep svn # kill -9 26221# svnadmin create /data/svn/ceshi# export LANG=en_US# svnadmin load /data/svn/ceshi < /data/20150906 # cat /data/passwd >> /data/svn/ceshi/conf/passwd
[users]admin:uyvcrbGbdBPuk
# vim /data/svn/ceshi/conf/authz 
 
[groups][/]admin = rw* =
# vim /data/svn/ceshi/conf/svnserve.conf 
[general]anon-access = noneauth-access = writepassword-db = /data/svn/ceshi/conf/passwdauthz-db = /data/svn/ceshi/conf/authz
# vim /etc/httpd/conf/httpd.conf
 
 
<Location /ceshi>DAV svnSVNPath /data/svn/ceshi/AuthType BasicAuthName "svn for ceshi"AuthUserFile /data/svn/ceshi/conf/passwdAuthzSVNAccessFile /data/svn/ceshi/conf/authzSatisfy allRequire valid-user</Location>
 
# Service httpd restart
# Svnserve-d-r/data/svn
Test whether recovery is successful
Http: // 192.168.5.10/ceshi

VII. Automatic full backup script

 # vim svn.pl
 
#! /Usr/bin/perl-wmy $ svn_repos = "/data/svn/project"; my $ backup_dir = "/data/backup/svn /"; my $ next_backup_file = "svn ". 'date + % Y % m % d'; $ youngest = 'svnlook youngest $ svn_repos '; chomp $ youngest; print "Backing up to revision $ youngest "; my $ svnadmin_cmd = "svnadmin dump -- revision $ youngest $ svn_repos> $ backup_dir/$ next_backup_file"; '$ svnadmin_cmd'; open (LOG, "> $ backup_dir/logs "); # record the Backup Version Number print LOG $ youngest; close LOG; # If you want to save space, execute the following compression script # print "Compressing dump file... n "; # print 'gzip-9 $ backup_dir/$ next_backup_file ';

Delete the backup file three days ago

# vim svn-Timing-delete.sh
find /data/backup/svn/  -type f -mtime +3 -exec rm '{}' \; 

Add to scheduled task

# crontab -e
30 22 * * * perl /data/svn/svn.pl00 23 * * * bash /data/svn/svn-Timing-delete.sh

Set up SVN server SVN in Ubuntu 14.04 ://

CentOS 6.2 SVN setup (YUM installation)

Deploy Apache + SVN in CentOS 6.5

Build an SVN server using Apache + SVN

Set up and use the SVN server in Windows + reset the password on the client

Install SVN in Ubuntu Server 12.04 and migrate Virtual SVN data

Build SVN service and migration method on Ubuntu Server

Subversion (SVN) Details: click here
Subversion (SVN): click here

This article permanently updates the link address:

Related Article

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.