Skip to content

Commit 9c41a7e

Browse files
committed
CA-409710: Clean old database backup files
The old database backup files should also be cleaned. Signed-off-by: Bengang Yuan <[email protected]>
1 parent 1b24182 commit 9c41a7e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/xe-backup-metadata

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ if [ ${leave_mounted} -eq 0 ]; then
222222
fi
223223

224224
# invoke logrotate to rotate over old pool db backups
225-
echo -n "Rotating old backups: "
225+
echo -n "Rotating old DB backups: "
226226
logrotate -f "${lrconf}"
227227
num_found=$(find "${mnt}" -name '*.db.*' | wc -l)
228228
echo "found ${num_found}"
@@ -232,6 +232,14 @@ if [ ${leave_mounted} -eq 0 ]; then
232232
${XE} pool-dump-database file-name="${mnt}/${pool_uuid}.db"
233233
echo done
234234

235+
# clean the old pool database dump
236+
echo -n "Cleaning old DB backups: "
237+
todelete=$(cd "${mnt}" && ls -1tr ${pool_uuid}.db* | head -n -${history_kept} | xargs echo)
238+
for dbfile in ${todelete}; do
239+
rm -f "${mnt}/${dbfile}"
240+
done
241+
echo done
242+
235243
# backup the VM metadata for each VM in the pool into a dated directory
236244
datetime=$(date +%F-%H-%M-%S)
237245
metadir="${mnt}/metadata/${datetime}"

0 commit comments

Comments
 (0)