EasyBackup

EasyBackup 鏄竴涓熀浜� Java 鐨勫厤璐瑰紑婧愯法骞冲彴鍐呭澶囦唤鍘嬬缉杩滅▼鍙戦€佷竴浣撳寲浠诲姟璋冨害搴旂敤鍙婂紩鎿庢鏋躲€傚嵆鍙紑绠卞嵆鐢�(EasyBackup Application)锛屽張鍙互浣滀负鍐呭澶囦唤寮曟搸妗嗘灦鎵╁睍(EasyBackup Engine Framework)銆�

EasyBackup 鑳藉涓洪渶瑕佽繘琛屽唴瀹瑰浠界殑绋嬪簭鍦烘櫙鎻愪緵涓€浣撳寲鏀寔銆傞泦鍚堜簡鍩轰簬浠诲姟璋冨害鐨勫唴瀹瑰浠斤紝鍐呭鍘嬬缉锛岃繙绋嬪彂閫侊紝鍛戒护鎵ц绛夌瓑鍔熻兘銆傝€岃繖涓€鍒囷紝浠呴渶杩涜绠€鍗曠殑閰嶇疆绠$悊鍗冲彲瀹屾垚銆�

鏈€鏂扮増鏈細 2.2.0-RELEASE

鎻掍欢锛�

EasyBackup 鐗圭偣

EasyBackup 涓昏缁勪欢

EasyBackup principal components

BackupConfiguration

Properties

easybackup.properties 鏄� EasyBackup 鐨勬牳蹇冮厤缃枃浠讹紝閰嶇疆浜嗗唴瀹瑰浠芥墍闇€鐨勬墍鏈変俊鎭€�

閰嶇疆缁撴瀯

EasyBackup Properties

鍏ㄥ眬閰嶇疆锛堜綔涓虹洃鎺ф湇鍔¢厤缃殑鍏ㄥ眬榛樿鍊硷紝鍙€夛級

# Backup ON or OFF, default is ON
# 澶囦唤鏈嶅姟榛樿鏄惁鎵撳紑锛岄粯璁や负 ON
easybackup.enable=ON

# Backup trigger Cron-Expressions
# 澶囦唤鏈嶅姟鐨勯粯璁よ皟搴� Cron-Expressions锛� 榛樿涓� '0 30 * * * ?'
easybackup.cronexpression=0 30 * * * ?

# Directory to store the backup file
# You can specify more than one, separated by a ##
# 鏂囦欢澶囦唤鐩綍锛屽涓浠界洰褰曚娇鐢� ## 鍒嗛殧
easybackup.dir=/user/backup/
# backup file name under 'easybackup.backup.dir' directory
# If not specified, the automatically generated file name is 'targetFileName-yyyyMMddHHmmssS[.zip|tar|tar.gz]'
# you can use variable: ${targetFileName}, ${name}, ${type}, ${value}, ${backuptime}, ${backupConfiguration.XXX}
# 鍦ㄦ枃浠跺浠界洰褰曚笅鐨勫浠界殑鏂囦欢鍚�
# 榛樿涓� 'targetFileName-yyyyMMddHHmmssS[.zip|tar|tar.gz]'
# 鍙互浣跨敤浠ヤ笅鍙橀噺锛�${targetFileName}, ${name}, ${type}, ${value}, ${backuptime?string("yyyyMMddHHmmssS")}, ${backupConfiguration.XXX}
easybackup.file=

# Whether backup compression, default is OFF
# 榛樿鏄惁浣跨敤鍘嬬缉澶囦唤锛岄粯璁や负 OFF
easybackup.compress=OFF
# Compression format: TAR(*.tar), ZIP(*.zip), GZIP(*.tar.gz), default is ZIP
# 鍘嬬缉澶囦唤浣跨敤鐨勫帇缂╂柟寮忥紝榛樿涓� ZIP
easybackup.compressType=ZIP
# Comprssion encoding
# 鍘嬬缉鏂囦欢浣跨敤鐨勭紪鐮佹牸寮�
easybackup.compressEncoding=

# Whether delete targetFile after backup complete, default is OFF
# 澶囦唤瀹屾垚鍚庯紝鏄惁鍒犻櫎宸插浠界殑鐩爣鏂囦欢锛岄粯璁や负 OFF
easybackup.deleteTargetFile=OFF

# Receive Backup file mail address
# You can specify more than one, separated by a ##
# 鎺ユ敹澶囦唤淇℃伅鐨勯偖绠卞垪琛紝澶氫釜閭浣跨敤 ## 鍒嗛殧
easybackup.mail.receiver=yourmail@domain.com##youmail2@domai2.org

# Send Mail Account Config
# 閭鍙戦€佽€呰处鎴烽厤缃�
# Send Mail Account
easybackup.mail.sender=sendermail@domain.com
# Send Mail password
# 閭鍙戦€佽€呭瘑鐮�
easybackup.mail.sender.passowrd=mailpassword
# Send Mail SMTP host
# 閭鍙戦€佽€� host
easybackup.mail.sender.host=smtp.163.com
# Send Mail SMTP port; default is 25
# 閭鍙戦€佽€� host 绔彛
easybackup.mail.sender.port=25
# Send Mail Whether use SSL; default is false
# 鏄惁浣跨敤浜� SSL 鍗忚
easybackup.mail.sender.ssl=false
# Send Mail title
# you can use variable: ${targetFileName}, ${name}, ${type}, ${value}, ${backuptime?datetime}, ${backupConfiguration.XXX}
# 閭欢鍙戦€佹爣棰�
# 鍙互浣跨敤浠ヤ笅鍙橀噺锛�${targetFileName}, ${name}, ${type}, ${value}, ${backuptime?datetime}, ${backupConfiguration.XXX}
easybackup.mail.sender.title=Backup ${targetFileName}- EasyBackup
# The send mail content freemarker template in template directory, default is 'mail.tpl'
# template 鐩綍涓嬬殑閭欢鍙戦€佹ā鏉匡紝榛樿涓� mail.tpl
easybackup.mail.sender.template=mail.tpl

# Auto delete when send email complete ON or OFF, default is OFF
# 澶囦唤鍙戦€佸埌閭鍚庯紝鏄惁鍒犻櫎澶囦唤鏂囦欢锛岄粯璁や负 OFF
easybackup.mail.deleteBackup=OFF

# Execute Command when backup before or after
# You can specify more than one, separated by a ##
# 澶囦唤寮€濮嬪墠鎴栧畬鎴愬悗鎵ц鐨勫墠缃拰鍚庣疆鍛戒护鑴氭湰锛屽涓懡浠よ剼鏈娇鐢� ## 鍒嗛殧
easybackup.cmd.before=
easybackup.cmd.after=

# Execute Interceptor when backup before or after
# You can specify more than one, separated by a ##
# 澶囦唤寮€濮嬪墠鎴栧畬鎴愬悗鎵ц鐨勫墠缃拰鍚庣疆澶勭悊绫伙紝澶氫釜绫诲畬鍏ㄩ檺瀹氬悕浣跨敤 ## 鍒嗛殧
easybackup.beforeClass=
easybackup.afterClass=

澶囦唤鏈嶅姟閰嶇疆锛堝彲浠ヨ鐩栧叏灞€閰嶇疆鐨勯粯璁ゅ€硷級

NAME 鏄嚜瀹氫箟鐨勭洃鎺ф湇鍔″悕绉帮紝姣忎釜鐩戞帶鏈嶅姟鐢变竴缁勭浉鍚� NAME 鐨勯厤缃」缁勬垚銆�

######################## Backup Service configuration
easybackup.[file|user].NAME=value
easybackup.[file|user].NAME.enable=ON | OFF
easybackup.[file|user].NAME.cronexpression=0/10 * * * * ?

easybackup.[file|user].NAME.dir=/user/backup/##/user/backup2
easybackup.[file|user].NAME.file=
easybackup.[file|user].NAME.compress=ON | OFF
easybackup.[file|user].NAME.compressType=ZIP | GZIP | TAR
easybackup.[file|user].NAME.compressEncoding=
easybackup.[file|user].NAME.deleteTargetFile=ON | OFF

easybackup.user.NAME.targetFileClass=package.YourTargetFile
easybackup.user.NAME.dirClass=package.YourBackupDir
easybackup.user.NAME.fileClass=package.YourBackupFile
easybackup.user.NAME.backupClass=package.YourBackup

easybackup.[file|user].NAME.cmd.before=/user/backupBefore.sh##/user/backupBefore2.sh
easybackup.[file|user].NAME.cmd.after=/user/backcAfter.sh##/user/backcAfter2.sh
easybackup.[file|user].NAME.beforeClass=package.BackupBefore##package.BackupBefore2
easybackup.[file|user].NAME.afterClass=package.BackupAfter##package.BackupAfter2

easybackup.[file|user].NAME.mail.receiver=receivermail@domain.com##receivermail1@domain.com

easybackup.[file|user].NAME.mail.sender=sendermail@domain.com
easybackup.[file|user].NAME.mail.sender.passowrd=sendermail_password
easybackup.[file|user].NAME.mail.sender.host=sendermail_host
easybackup.[file|user].NAME.mail.sender.port=sendermail_port
easybackup.[file|user].NAME.mail.sender.ssl=sendermail_ssh
easybackup.[file|user].NAME.mail.sender.title=sendermail_title
easybackup.[file|user].NAME.mail.sender.template=mail.tpl
easybackup.[file|user].NAME.mail.deleteBackup=ON | OFF

easybackup.[file|user].NAME.senders=package.userSenderClass##package.userSenderClass2

User 鑷畾涔夐厤缃鏄�

鍙橀噺浣跨敤

瀹屽叏閰嶇疆绀轰緥

######################## Global Config(Optional) 鍏ㄥ眬閰嶇疆锛堝彲閫夛級

# Backup ON or OFF, default is ON
# 澶囦唤鏈嶅姟榛樿鏄惁鎵撳紑锛岄粯璁や负 ON
easybackup.enable=ON

# Backup trigger Cron-Expressions
# 澶囦唤鏈嶅姟鐨勯粯璁よ皟搴� Cron-Expressions锛� 榛樿涓� '0 30 * * * ?'
easybackup.cronexpression=0 30 * * * ?

# Directory to store the backup file
# You can specify more than one, separated by a ##
# 鏂囦欢澶囦唤鐩綍锛屽涓浠界洰褰曚娇鐢� ## 鍒嗛殧
easybackup.dir=/user/backup/
# backup file name under 'easybackup.backup.dir' directory
# If not specified, the automatically generated file name is 'targetFileName-yyyyMMddHHmmssS[.zip|tar|tar.gz]'
# you can use variable: ${targetFileName}, ${name}, ${type}, ${value}, ${backuptime}, ${backupConfiguration.XXX}
# 鍦ㄦ枃浠跺浠界洰褰曚笅鐨勫浠界殑鏂囦欢鍚�
# 榛樿涓� 'targetFileName-yyyyMMddHHmmssS[.zip|tar|tar.gz]'
# 鍙互浣跨敤浠ヤ笅鍙橀噺锛�${targetFileName}, ${name}, ${type}, ${value}, ${backuptime?string("yyyyMMddHHmmssS")}, ${backupConfiguration.XXX}
easybackup.file=

# Whether backup compression, default is OFF
# 榛樿鏄惁浣跨敤鍘嬬缉澶囦唤锛岄粯璁や负 OFF
easybackup.compress=OFF
# Compression format: TAR(*.tar), ZIP(*.zip), GZIP(*.tar.gz), default is ZIP
# 鍘嬬缉澶囦唤浣跨敤鐨勫帇缂╂柟寮忥紝榛樿涓� ZIP
easybackup.compressType=ZIP
# Comprssion encoding
# 鍘嬬缉鏂囦欢浣跨敤鐨勭紪鐮佹牸寮�
easybackup.compressEncoding=

# Whether delete targetFile after backup complete, default is OFF
# 澶囦唤瀹屾垚鍚庯紝鏄惁鍒犻櫎宸插浠界殑鐩爣鏂囦欢锛岄粯璁や负 OFF
easybackup.deleteTargetFile=OFF

# Receive Backup file mail address
# You can specify more than one, separated by a ##
# 鎺ユ敹澶囦唤淇℃伅鐨勯偖绠卞垪琛紝澶氫釜閭浣跨敤 ## 鍒嗛殧
easybackup.mail.receiver=yourmail@domain.com##youmail2@domai2.org

# Send Mail Account Config
# 閭鍙戦€佽€呰处鎴烽厤缃�
# Send Mail Account
easybackup.mail.sender=sendermail@domain.com
# Send Mail password
# 閭鍙戦€佽€呭瘑鐮�
easybackup.mail.sender.passowrd=mailpassword
# Send Mail SMTP host
# 閭鍙戦€佽€� host
easybackup.mail.sender.host=smtp.163.com
# Send Mail SMTP port; default is 25
# 閭鍙戦€佽€� host 绔彛
easybackup.mail.sender.port=25
# Send Mail Whether use SSL; default is false
# 鏄惁浣跨敤浜� SSL 鍗忚
easybackup.mail.sender.ssl=false
# Send Mail title
# you can use variable: ${targetFileName}, ${name}, ${type}, ${value}, ${backuptime?datetime}, ${backupConfiguration.XXX}
# 閭欢鍙戦€佹爣棰�
# 鍙互浣跨敤浠ヤ笅鍙橀噺锛�${targetFileName}, ${name}, ${type}, ${value}, ${backuptime?datetime}, ${backupConfiguration.XXX}
easybackup.mail.sender.title=Backup ${targetFileName}- EasyBackup
# The send mail content freemarker template in template directory, default is 'mail.tpl'
# template 鐩綍涓嬬殑閭欢鍙戦€佹ā鏉匡紝榛樿涓� mail.tpl
easybackup.mail.sender.template=mail.tpl

# Auto delete when send email complete ON or OFF, default is OFF
# 澶囦唤鍙戦€佸埌閭鍚庯紝鏄惁鍒犻櫎澶囦唤鏂囦欢锛岄粯璁や负 OFF
easybackup.mail.deleteBackup=OFF

# Execute Command when backup before or after
# You can specify more than one, separated by a ##
# 澶囦唤寮€濮嬪墠鎴栧畬鎴愬悗鎵ц鐨勫墠缃拰鍚庣疆鍛戒护鑴氭湰锛屽涓懡浠よ剼鏈娇鐢� ## 鍒嗛殧
easybackup.cmd.before=
easybackup.cmd.after=

# Execute Interceptor when backup before or after
# You can specify more than one, separated by a ##
# 澶囦唤寮€濮嬪墠鎴栧畬鎴愬悗鎵ц鐨勫墠缃拰鍚庣疆澶勭悊绫伙紝澶氫釜绫诲畬鍏ㄩ檺瀹氬悕浣跨敤 ## 鍒嗛殧
easybackup.beforeClass=
easybackup.afterClass=


########################  Backup Service Configuration 鐩戞帶閰嶇疆

############ File Backup(can override global config)
## format: 
## easybackup.file.NAME=value
## easybackup.file.NAME.enable=ON | OFF
## easybackup.file.NAME.cronexpression=0/10 * * * * ?
## easybackup.file.NAME.dir=/user/backup/##/user/backup2
## easybackup.file.NAME.file=
## easybackup.file.NAME.compress=ON | OFF
## easybackup.file.NAME.compressType=ZIP | GZIP | TAR
## easybackup.file.NAME.compressEncoding=
## easybackup.file.NAME.deleteTargetFile=ON | OFF
## easybackup.file.NAME.cmd.before=/user/backupBefore.sh##/user/backupBefore2.sh
## easybackup.file.NAME.cmd.after=/user/backcAfter.sh##/user/backcAfter2.sh
## easybackup.file.NAME.beforeClass=package.BackupBefore##package.BackupBefore2
## easybackup.file.NAME.afterClass=package.BackupAfter##package.BackupAfter2
## easybackup.file.NAME.mail.receiver=receivermail@domain.com##receivermail1@domain.com
## easybackup.file.NAME.mail.sender=sendermail@domain.com
## easybackup.file.NAME.mail.sender.passowrd=sendermail_password
## easybackup.file.NAME.mail.sender.host=sendermail_host
## easybackup.file.NAME.mail.sender.port=sendermail_port
## easybackup.file.NAME.mail.sender.ssl=sendermail_ssh
## easybackup.file.NAME.mail.sender.title=sendermail_title
## easybackup.file.NAME.mail.sender.template=mail.tpl
## easybackup.file.NAME.mail.deleteBackup=ON | OFF
## easybackup.file.NAME.senders=package.userSenderClass##package.userSenderClass2



# Example:
easybackup.file.LOG=D:/log
easybackup.file.LOG.enable=ON
easybackup.file.LOG.dir=D:/backup/logfile/##E:/backup/logfile
easybackup.file.LOG.cronexpression=0 30 * * * ?
easybackup.file.LOG.compress=ON
easybackup.file.LOG.compressType=ZIP
#easybackup.file.LOG.mail.receiver=mail@domain.com


############ Port Monitor(can override global config)
## format: 
## easybackup.user.NAME=value
## easybackup.user.NAME.enable=ON | OFF
## easybackup.user.NAME.cronexpression=0/10 * * * * ?
## easybackup.user.NAME.dir=/user/backup/##/user/backup2
## easybackup.user.NAME.file=
## easybackup.user.NAME.compress=ON | OFF
## easybackup.user.NAME.compressType=ZIP | GZIP | TAR
## easybackup.user.NAME.compressEncoding=
## easybackup.user.NAME.deleteTargetFile=ON | OFF
## easybackup.user.NAME.targetFileClass=package.YourTargetFile
## easybackup.user.NAME.dirClass=package.YourBackupDir
## easybackup.user.NAME.fileClass=package.YourBackupFile
## easybackup.user.NAME.backupClass=package.YourBackup
## easybackup.user.NAME.cmd.before=/user/backupBefore.sh##/user/backupBefore2.sh
## easybackup.user.NAME.cmd.after=/user/backcAfter.sh##/user/backcAfter2.sh
## easybackup.user.NAME.beforeClass=package.BackupBefore##package.BackupBefore2
## easybackup.user.NAME.afterClass=package.BackupAfter##package.BackupAfter2
## easybackup.user.NAME.mail.receiver=receivermail@domain.com##receivermail1@domain.com
## easybackup.user.NAME.mail.sender=sendermail@domain.com
## easybackup.user.NAME.mail.sender.passowrd=sendermail_password
## easybackup.user.NAME.mail.sender.host=sendermail_host
## easybackup.user.NAME.mail.sender.port=sendermail_port
## easybackup.user.NAME.mail.sender.ssl=sendermail_ssh
## easybackup.user.NAME.mail.sender.title=sendermail_title
## easybackup.user.NAME.mail.sender.template=mail.tpl
## easybackup.user.NAME.mail.deleteBackup=ON | OFF
## easybackup.user.NAME.senders=package.userSenderClass##package.userSenderClass2

# Example:
easybackup.user.MySQL=mysqldump -uroot -proot demoDB 
easybackup.user.MySQL.targetFileClass=cn.easyproject.easybackup.mysql.MySQLTargetFile
easybackup.user.MySQL.dir=D:/backup/##E:/backupdb
# default targetFileName is 'demoDB-yyyyMMddHHmmssS.sql'
# you can use variable: ${targetFileName}, ${name}, ${type}, ${value}, ${backuptime?string("yyyyMMddHHmmssS")}, ${backupConfiguration.XXX}
easybackup.user.MySQL.file= demodb-${backuptime?string("yyyyMMddHHmmss")}-backup.sql
easybackup.user.MySQL.compress=ON
easybackup.user.MySQL.compressType=ZIP
easybackup.user.MySQL.cronexpression=0 0 2 * * ?
#easybackup.user.MySQL.mail.receiver=mail@domain.com

閭欢妯℃澘閰嶇疆

EasyBackup 浣跨敤浜� freemarker 妯℃澘鎶€鏈繘琛岄偖浠跺唴瀹规覆鏌擄紝妯℃澘蹇呴』瀛樻斁鍦� template 鐩綍涓嬶紝榛樿浣跨敤 mail.tpl 妯℃澘銆�

mail.tpl

鑷畾涔夋ā鏉块厤缃�

鎮ㄥ彲浠ョ洿鎺ヤ慨鏀规ā鏉垮唴瀹癸紝鎴栬€呯紪鍐欐偍鑷繁鐨勯偖浠跺彂閫佹ā鏉裤€�

### Global configuration
easybackup.mail.sender.template=yourmail.tpl

### Monitor Service configuration
easybackup.[file|user].NAME.mail.sender.template=yourmail.tpl

妯℃澘鍐呯疆鍙橀噺

${targetFileName}锛氬浠界殑妯℃澘鏂囦欢鍚�
${type}锛氬浠界被鍨嬶紙FILE銆�USER锛�
${name}锛氬浠芥湇鍔″悕绉�
${value}锛氬浠芥湇鍔″€�
${backuptime}锛氬浠芥椂闂�
${backupConfiguration.XXX}锛氬浠介厤缃璞″睘鎬�

EasBackup Application

EasBackup Application 鏄紑绠卞嵆鐢ㄧ殑 EasBackup 澶囦唤搴旂敤銆傛寜闇€閰嶇疆鎮ㄧ殑澶囦唤鏈嶅姟锛屽惎鍔ㄥ嵆鍙€�

EasyBackup Application 宸茬粡鍖呭惈浜嗗綋鍓嶅畼鏂圭殑鑰屾墍鏈夋彃浠躲€傚鏋滄偍寮€鍙戜簡鏂扮殑鎻掍欢锛屽彲浠ュ皢鎻掍欢鐨勫唴瀹圭洿鎺ユ坊鍔犲埌 easybackup-X.X.X-RELEASE-APPLICATION.jar 涓€�

鍐呯疆鎻掍欢锛�

浣跨敤姝ラ

  1. 閰嶇疆澶囦唤鏈嶅姟

    鍙傝€� easybackup.properties 涓殑绀轰緥锛岄厤缃偍鐨勫浠芥湇鍔°€�

  2. 杩愯 EasyBackup

    • Windows(Sometimes you must 'Run as Administrator')

      Start:  startup.bat
      Stop:   shutdown.bat
    • Linux

      Start:  ./startup.sh
      Stop:   ./shutdown.sh
  3. 鍙€夐厤缃�

    1. 閭欢妯℃澘 Mail template

      淇敼 'template/mail.tpl' 瀹氬埗鎮ㄧ殑閭欢鍐呭銆�

    2. 鏃ュ織 Logger

      閰嶇疆 log4j.properties 鏃ュ織杈撳嚭銆�

EasyBackup Engine Framework

EasyBackup 鍚屾椂鏄竴涓厤璐瑰紑婧愯法骞冲彴鐨� Java 鍐呭澶囦唤寮曟搸妗嗘灦(EasyBackup Engine Framework)锛屾彁渚涚粺涓€瑙勮寖鐨勫浠介厤缃拰鏍稿績璋冨害銆�

浣跨敤姝ラ

  1. Maven dependency

    <dependency>
       <groupId>cn.easyproject</groupId>
       <artifactId>easybackup</artifactId>
       <version>2.2.0-RELEASE</version>
    </dependency>
  2. 鑷畾涔夋帴鍙e疄鐜�

  3. 閰嶇疆 easybackup.properties

  4. 鍚姩

    public static void main(String[] args) {
        new EasyBackup().start();
    }

鑷畾涔夋帴鍙�

EasyBackup 鎻愪緵浜嗘瀬澶х殑鐏垫椿鎬э紝鎵╁睍浠ヤ笅鎺ュ彛锛屽嵆鍙嚜瀹氫箟鎮ㄧ殑澶囦唤鍐呭锛�

End

瀹樻柟涓婚〉

鐣欒█璇勮

濡傛灉鎮ㄦ湁鏇村ソ鎰忚锛屽缓璁垨鎯虫硶锛岃鑱旂郴鎴戙€�

Email锛�inthinkcolor@gmail.com

http://www.easyproject.cn

鏀粯瀹濋挶鍖呮壂涓€鎵崘鍔�