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?

WindowsローカルのMySQL定期バックアップ設定

Posted at

PowerShellでパスワードファイルを作成

mysql_config_editor set --login-path=mybackup --host=localhost --user=root --password

Enter password:パスワード入力

暗号化された設定がC:\Users<ユーザー>.mylogin.cnf に保存されます。

PowerShellコマンドをps1ファイルに保存

$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$backupFile = "C:\バックアップを保存するフォルダのパス\workrecords_backup_$timestamp.sql"

& "C:\Program Files\MySQL\MySQL Server 8.4\bin\mysqldump.exe" `
    --login-path=mybackup `
    --no-tablespaces --single-transaction データベース名 `
    > $backupFile

タスクスケジューラー設定

全般

✔︎ユーザーがログインしているかどうかにかかわらず実行
✔︎最上位の特権で実行する

トリガー

スケジュールに従う
希望する間隔
希望する日時
✔︎有効

操作

操作:プログラムの開始
プログラム/スクリプト:
PowerShellのパスC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
引数の追加:

-ExecutionPolicy Bypass -File "C:\Users\t-hik\Documents\Others\WorkRecords\TimeRecorderApp\DBBackupSystem\CronSystem\DBBackupScript.ps1"

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?