我对 bacula 有信心。我尝试在工作后删除文件,但它不起作用:(
部分我的conf:
Job {
Name = "spass.mysql"
Type = Backup
Level = Full
Client = spass-fd
RunScript {
RunsWhen = Before
FailJobOnError = No
RunsOnClient = Yes
Command = "/usr/bin/mysqldump -EB syspass --result-file /tmp/syspass-%i.sql"
}
Client Run After Job = "/usr/bin/rm -f /tmp/*.sql"
Schedule = "WorkTimeEveryHour"
Storage = File-spass
Pool = spass
FileSet="spass.mysql"
Messages = Standard
Priority = 10
Write Bootstrap = "/var/spool/bacula/%c_%n_%e.bsr"
}
FileSet {
Name = "spass.mysql"
Include {
Options {
signature = MD5
compression = GZIP
wildfile = "*.sql"
}
Options {
Exclude = yes
RegexFile = ".*"
RegexDir = ".*"
}
File = /tmp/
}
}
在消息中可以:
14-Jun 17:02 bnode10-dir JobId 364: Start Backup JobId 364, Job=spass.mysql.2017-06-14_17.02.09_10
14-Jun 17:02 bnode10-dir JobId 364: Using Device "FileStorage-spass" to write.
14-Jun 17:02 spass-fd JobId 364: shell command: run ClientBeforeJob "/usr/bin/mysqldump -EB syspass --result-file /tmp/syspass-364.sql"
14-Jun 17:02 bacula-sd JobId 364: Volume "spass0006" previously written, moving to end of data.
14-Jun 17:02 bacula-sd JobId 364: Ready to append to end of Volume "spass0006" size=995952259
14-Jun 17:02 spass-fd JobId 364: shell command: run ClientAfterJob "/usr/bin/rm -f /tmp/*.sql"
14-Jun 17:02 bacula-sd JobId 364: Elapsed time=00:00:01, Transfer rate=200.8 K Bytes/second
14-Jun 17:02 bnode10-dir JobId 364: Bacula bnode10-dir 5.2.13 (19Jan13):
如何解决?
PS。我认为麻烦是许可。但不知道如何解决它
您可以将命令放入脚本中,并在控制台上输出。
Bacula 会将此输出写入您工作的日志文件中。
像你一样,我有一份保存数据库转储的工作。为此,我有一个在作业前进行转储的脚本和一个在作业后删除转储的脚本。
我的脚本在工作之前进行转储的示例(它在 powershell 中,但想法是一样的):
如果转储正常,我在 bacula 作业日志中有一条“转储正常”行:
有了它,您可以检查脚本的输出以及它会出现错误的位置。
您需要将呼叫包装在外壳中。只是简单地调用
rm /tmp/*.sql
不会应用通配符,因此它会删除/tmp/*.sql
不存在的调用文件。正如您所说,也没有警告-f
尝试使用Client Run After Job = "/usr/bin/bash -c '/usr/bin/rm -f /tmp/*.sql'"
它将在 bash 中运行您的命令,然后执行 globbing。