File tree 2 files changed +14
-1
lines changed
2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 8
8
# [*backupdir*] - The target directory of the mysqldump.
9
9
# [*backupcompress*] - Boolean to compress backup with bzip2.
10
10
# [*backuprotate*] - Number of backups to keep. Default 30
11
+ # [*delete_before_dump*] - Clean existing backups before creating new
11
12
#
12
13
# Actions:
13
14
# GRANT SELECT, RELOAD, LOCK TABLES ON *.* TO 'user'@'localhost'
30
31
$backupdir,
31
32
$backupcompress = true ,
32
33
$backuprotate = 30,
34
+ $delete_before_dump = false ,
33
35
$ensure = ' present'
34
36
) {
35
37
Original file line number Diff line number Diff line change @@ -22,10 +22,21 @@ PATH=/usr/bin:/usr/sbin:/bin:/sbin
22
22
23
23
set -o pipefail
24
24
25
+ cleanup ()
26
+ {
27
+ find " ${DIR} /" -maxdepth 1 -type f -name " ${PREFIX} *.sql*" -mtime +${ROTATE} -print0 | xargs -0 -r rm -f
28
+ }
29
+
30
+ < % if @delete_before_dump -%>
31
+ cleanup
32
+
33
+ < % end -%>
25
34
mysqldump -u${USER} -p${PASS} --opt --flush-logs --single-transaction \
26
35
--all-databases < % if @backupcompress %> | bzcat -zc < % end %>> ${DIR} /${PREFIX} ` date +%Y%m%d-%H%M%S` .sql< % if @backupcompress %> .bz2< % end %>
27
36
37
+ < % if not @delete_before_dump -%>
28
38
if [ $? -eq 0 ] ; then
29
- find " ${DIR} / " -maxdepth 1 -type f -name " ${PREFIX} *.sql* " -mtime + ${ROTATE} -print0 | xargs -0 -r rm -f
39
+ cleanup
30
40
fi
41
+ < % end -%>
31
42
You can’t perform that action at this time.
0 commit comments