我想通过cron维护多个带日期的备份,但似乎无法弄清楚如何在cron中连接文件名。
目前,我只使用以下内容:
/bin/mv /var/www/vhosts/mysite.org/dbBackups/today.sql /var/www/vhosts/mysite.org/dbBackups/yesterday.sql
/usr/bin/mysqldump --add-drop-table -u dbname -pmypass dbname > /var/www/vhosts/mysite.org/dbBackups/today.sql
我尝试过的不好:
/usr/bin/mysqldump/mysqldump --add-drop-table -u dbname -pmypass dbname > '/var/www/vhosts/mysite.org/dbBackups/' . date +%Y%m%d . dbname.sql
那么,如何在cron中保留该字符串呢?
最佳答案
/usr/bin/mysqldump/mysqldump --add-drop-table -u dbname -pmypass dbname > "/var/www/vhosts/mysite.org/dbBackups/"`date +%Y%m%d`dbname.sql
关于unix - 使用日期将文件名附加到cron进行的数据库备份中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1329465/