Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
cronでタスクを実行して、すべてのデータベースを1つのファイルにエクスポートしたいと思います。曜日ごとに1つのファイルを作成したいと思います(例all_[1-7].sql)。また、前のファイルが存在する場合はそれを置き換えてほしい。MySQLの日付と時刻の関数を使用することは可能ですか?例:
all_[1-7].sql
mysqldump -u user -ppass –all-databases | gzip > /backups/mysql/all_`DAYOFMONTH(CURDATE())`.sql.gz
いいえ。パイプ文字がMySQLではなくシェルコマンドを実行した後に何が起こりますか。したがって、「シェルウェイ」の日付を生成する必要があります。例えば
... | gzip > /backups/mysql/all_`date +%u`.sql.gz