Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of SVN double backup Shell script for Linux Operation and maintenance CentOS system

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "Linux operation and maintenance CentOS system SVN double backup Shell script example analysis", the content is easy to understand, well-organized, hope to help you solve your doubts, the following let the editor lead you to study and learn "Linux operation and maintenance CentOS system SVN double backup Shell script example analysis" this article.

Preface

SVN is the abbreviation of Subversion, is an open source version control system, using a branch management system. To put it simply, SVN is the purpose for multiple people to jointly develop the same project and share resources.

As a code management tool, backup operation is particularly important. Here, a backup strategy is adopted: while performing a local backup, let the Shell script automatically upload data to another FTP backup server. This remote backup strategy costs less, does not need storage, and has a high security system. The probability of data corruption in both local and remote locations is much lower.

Backup policy description

Using the CentOS 6 series system, install vsftpd and modify the configuration parameters. In addition, the backup directory of vsftpd can be RAID1 or RAID5.

Execute a script to back up the local directory of the svn project, and then upload the backup file to the FTP server. Double backup has been achieved.

Backup step

Install and configure vsftpd

You can install it directly using yum.

Yum-y install vsftpd

Modify the configuration to allow users to upload because of the upload operation. Anonymous user operations are not recommended for security reasons.

After modifying the configuration, the unnecessary vsftpd.conf parameters are shielded and displayed as:

[root@private ~] # grep-v "^ #" / etc/vsftpd/vsftpd.conf | grep-v "^ $" anonymous_enable=NOlocal_enable=YESwrite_enable=YESlocal_umask=022dirmessage_enable=YESxferlog_enable=YESconnect_from_port_20=YESxferlog_std_format=YESchroot_local_user=YESlisten=YESpam_service_name=vsftpduserlist_enable=YEStcp_wrappers=YES

The statement chroot_local_user=YES needs to be emphasized. Its function is to restrict users' login permissions, that is, all local users can only log in to their own home directory when logging in to vsftpd. This is based on security considerations. This example script will also be based on this point. If you use this script in the actual production environment, you need to pay attention to this point.

Create a ftp login user

Create a backup user on the backup server, this time create the user svn and assign it a password, and change their home directory to the backup directory, the local backup directory is: / data/backup/svn-backup/, which makes it easier to backup, and so on.

[root@private ~] # useradd-d / data/backup/svn-backup/ svn [root@private ~] # echo "svnpasswd" | passwd-- stdin svnChanging password for user svn.passwd: all authentication tokens updated successfully.

Configure svn Warehouse

First, check whether subversion is installed on the operating system. This software is installed by default in general centos operating systems. If it is not installed, use the following command to install it quickly.

Rpm-qa subversionyum-y install subversion## create a version library svnadmin create / data/svn / / set the file directory here # # configure svnserve. After the above version library `/ data/svn` is established, a conf folder will be generated under the folder After entering `/ data/svn/ conf`, there are three files [root@private svn] # ls conf/authz passwd svnserve.conf # # need to modify `svnserve.conf` to modify the following sections: anon-access = read auth-access = write password-db = passwd authz-db = authz # # modify the `passw d` file to: [users] username = password / / username and password settings here # # configuration file `authz` finally add the following two lines (these two lines) Solved the SVN client to solve the authorization failed problem) [/] * = rw # # start svnserve: svnserve-d-r / home/myrepos/

Backup script

This script sets the polling period to once every 30 days, and Shell will automatically delete files that are 30 days old. Create the corresponding backup user svn script in vsftpd as follows:

#! / bin/bashSVNDIR= "/ data" SVNADMIN= "/ usr/bin/svnadmin" DATE=$ (date +% Y-%m-%d) OLDDATE=$ (date +% Y-%m-%d-dumb30 days') BACKDIR= "/ data/backup/svn-backup" [- d ${BACKDIR}] | | mkdir-p ${BACKDIR} LogFile=$ {BACKDIR} / svnbak.log [- f ${LogFile}] | touch ${LogFile} mkdir ${BACKDIR} / ${DATE} for PROJECT in svndo cd $SVNDIR $SVNADMIN hotcopy $PROJECT $BACKDIR/$DATE/$PROJECT-- clean-logs cd $BACKDIR/$DATE tar zcvf ${PROJECT} _ svn_$ {DATE} .tar.gz $PROJECT > / dev/null rm-rf $PROJECT sleep 2doneHOST=localhostFTP_USERNAME=svnFTP_PASSWORD=Haiyuancd ${BACKDIR} / ${DATE} ftp-I-n-v is all the content of the article "sample Analysis of SVN double backup Shell script for Linux Operation and maintenance CentOS system" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report