Regular and complete backup scripts for SubVersion on linux

Source: Internet
Author: User
Article Title: Regular and complete backup scripts for SubVersion on linux. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Note: Please adjust the settings as needed. I tested that running on my machine is normal. My environment is Centos5. My svn directory is on/svn.

In addition, remember to create the following directory under your/

# Mkdir-p/backup/svn/data/

# Mkdir-p/backup/svn/daily/

Script Function: regularly backs up complete projects.

The format of the project. lst file is as follows:

Project1

Project2

The backup script is as follows:

#! /Bin/sh

#

#

# Subversion: complete backup script. After adjustment, use crontab-e to automatically execute the script.

#

# Backing up log files

LogFile =/backup/svn/svnbak. log

DATE = 'date + % Y % m % d'

# Backup Directory

BakDir =/backup/svn/data

# Daily backup directory, if any

DailyDir =/backup/svn/daily

# The project list file to be backed up, with only the project name

ProjectLst =/backup/svn/project. lst

# All projects are saved in this directory.

SvnDir =/svn

# Svnadmin program path

SVNADMIN =/usr/bin/svnadmin

Echo ""> $ LogFile

Echo ""> $ LogFile

Echo "-----------------------------------------"> $ LogFile

Echo $ (date + "% y-% m-% d % H: % M: % S") >>$ LogFile

Echo "--------------------------"> $ LogFile

Cd $ BakDir

# Reading the project list

PROJECTLIST = 'cat $ projectlst'


For project in $ PROJECTLIST

Do

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 adjust the time according to crontab. For example, if a backup is performed once a week, five copies are retained here.

Oldfile = "$ BakDir/" $ (date + % y % m % d -- date = '28 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 *

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.