Subversion regular Full backup script (Linux) __linux

Source: Internet
Author: User
Tags svn

Scripting features: Periodically make a full backup of some items.

The Project.lst file format is as follows:

Project1
Project2

The backup script is as follows:

#!/bin/sh

#
# Subversion Data Backup script
# by Scud Http://www.jscud.com
# 2005-11-27
#
# Subversion full backup of the script, after adjusting the use of CRONTAB-E into the automatic execution can be.
#

#备份日志文件
Logfile=/backup/svn/svnbak.log

Date= ' Date +%y%m%d '

#备份目录
Bakdir=/backup/svn/data

#日常备份目录, if any
Dailydir=/backup/svn/daily

#要备份的项目列表文件, only the project name
Projectlst=/backup/svn/project.lst

#所有项目都保存在这个目录下
Svndir=/var/svn

#svnadmin程序的路径
Svnadmin=/app/subversion/bin/svnadmin

echo "" >> $LogFile
echo "" >> $LogFile
echo "-------------------------------------------" >> $LogFile
echo $ (date + "%y-%m-%d%h:%m:%s") >> $LogFile
echo "--------------------------" >> $LogFile

CD $BakDir

#读取项目列表
Projectlist= ' Cat $ProjectLst '


For project in $PROJECTLIST
Todo
Projectdata= $SvnDir/$project
destdir= $BakDir/$project
Dumpfile= $DATE. $project. tgz


If [f $BakDir/$dumpfile]
Then
echo "Backup file have exist!" >> $LogFile
Else

$SVNADMIN hotcopy $projectdata $destdir--clean-logs

Tar czvf $dumpfile $destdir >/dev/null

RM-FR $project

echo "Backup $project done into $dumpfile" >> $LogFile

Fi

# # Delete old tgz This is based on crontab time adjustments, such as a weekly backup, where 5 copies are kept, previous deletions
oldfile= "$BakDir/" $ (date +%y%m%d--date= ' days ago '). $project. tgz

If [f $oldfile]
Then
Rm-f $oldfile >> $LogFile 2>&1
echo "[$oldfile]delete old File success!" >> $LogFile
Else
echo "[$oldfile]no old Backup file!" >> $LogFile
Fi

Done


#delete previous daily backup files
CD $DailyDir
Rm-f *




After you configure your settings, use the crontab to put it on a scheduled task.

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.