0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

redmineのdbをlinuxからwindowsサーバにバックアップ

Posted at

redmineのdbをバックアップ

mysql_backup.sh
# !/bin/sh

dumpfile=/tmp/redmine_`date "+%Y%m%d%H%M"`.dump

find /tmp -mtime +14 -name '*_*.dump' -exec rm -f {} \; >/dev/null 2>&1
mysqldump --defaults-extra-file=/etc/redmine_my.cnf --single-transaction redmine > $dumpfile

exit 0

取得したdumpをwindowsサーバにアップロード

send_file_srv.bat
set DATE_NOW=%date:~0,4%%date:~5,2%%date:~8,2%
set TARGET_DIR=\\Foo\hoge\redmine\%DATE_NOW%
mkdir %TARGET_DIR%

cd "%~dp0%"
start "send_dump"
cscript send_file_srv.vbs

timeout 5
cp *.dump %TARGET_DIR%
del *.dump

pause
send_file_srv.vbs
set WshShell = WScript.CreateObject("WScript.Shell")
strScpCmd = "scp -P 4400 foo@hoge:/tmp/redmine_"+ Replace(Left(Now(),10), "/", "")+"*dump .~"
WshShell.AppActivate "send_dump"
WshShell.SendKeys strScpCmd
WScript.Sleep 10000
WshShell.SendKeys "PASSWORD~"
WScript.Sleep 1000
WshShell.SendKeys "exit~"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?