first
This commit is contained in:
commit
5d263730e4
4 changed files with 95 additions and 0 deletions
23
btrbk.conf
Normal file
23
btrbk.conf
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
snapshot_preserve_min 7d
|
||||||
|
snapshot_preserve 14d
|
||||||
|
|
||||||
|
target_preserve_min latest
|
||||||
|
target_preserve 3d 1w 1m
|
||||||
|
|
||||||
|
snapshot_dir btrbk_snapshots
|
||||||
|
|
||||||
|
incremental yes
|
||||||
|
|
||||||
|
# first btrfs volume
|
||||||
|
volume /mnt/cloud
|
||||||
|
target /mnt/backup
|
||||||
|
subvolume seafile
|
||||||
|
subvolume geoserver
|
||||||
|
subvolume onlynext
|
||||||
|
subvolume rocket_chat
|
||||||
|
|
||||||
|
# second btrfs volume
|
||||||
|
volume /mnt/data
|
||||||
|
target /mnt/backup
|
||||||
|
subvolume db_rocket.chat
|
||||||
|
subvolume nextcloud_db
|
19
btrfs_bckp.sh
Normal file
19
btrfs_bckp.sh
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
# EXAMPLE CRONJOB:
|
||||||
|
# 0 2 * * * /mnt/cloud/nc_dmcl/btrbk/btrfs_bckp.sh > /var/log/backup/btrfs_log.log
|
||||||
|
|
||||||
|
# stop services and snapshot
|
||||||
|
|
||||||
|
#Backup
|
||||||
|
# brtbk was present as a local copy in /mnt/cloud/nc_dmcl/btrbk ...
|
||||||
|
cd /mnt/cloud/nc_dmcl/btrbk/
|
||||||
|
./btrbk -c /mnt/cloud/nc_dmcl/btrbk/btrbk.conf run
|
||||||
|
btrfs device stats /mnt/cloud/
|
||||||
|
btrfs device stats /mnt/backup/
|
||||||
|
btrfs device stats /mnt/db_ssd/
|
||||||
|
|
||||||
|
# send mail with logfile
|
||||||
|
docker run --rm -v /var/log/backup/:/attachment mcr.microsoft.com/powershell pwsh /external/sendEmail.ps1
|
||||||
|
|
||||||
|
# start services
|
||||||
|
|
12
btrfs_scrub.sh
Normal file
12
btrfs_scrub.sh
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# 0 0 * * SAT /mnt/cloud/nc_dmcl/btrbk/btrfs_scrub.sh > /var/log/backup/btrfs_log.log
|
||||||
|
|
||||||
|
for fs in $(grep ' btrfs ' /proc/mounts | cut -d' ' -f1 | sort -u)
|
||||||
|
do
|
||||||
|
starttime="$(date "+%Y-%m-%d %H:%M:%S")"
|
||||||
|
printf "Starting btrfs scrub on $fs"
|
||||||
|
btrfs scrub start -Bd "$fs"
|
||||||
|
journalctl -q -k --since "$starttime" | grep BTRFS
|
||||||
|
printf "Scrub for $fs has finished"
|
||||||
|
done
|
||||||
|
|
||||||
|
docker run --rm -v /mnt/cloud/nc_dmcl/btrbk/scrub/:/attachment mcr.microsoft.com/powershell pwsh /external/sendEmail.ps1
|
41
sendEmail.ps1
Normal file
41
sendEmail.ps1
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<#
|
||||||
|
Simple script to send a log file after btrfs backup
|
||||||
|
#>
|
||||||
|
|
||||||
|
$EmailAttachments = "/attachment/btrfs_log.log"
|
||||||
|
|
||||||
|
# Email Setup
|
||||||
|
$SMTPServer = "mx.digimapas.cl"
|
||||||
|
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
|
||||||
|
$SMTPClient.EnableSsl = $true
|
||||||
|
$user = "no_reply_it@digimapas.cl"
|
||||||
|
$pw = ConvertTo-SecureString "PASSWORD" -AsPlainText -Force
|
||||||
|
$SMTPClient.Credentials = New-Object System.Management.Automation.PSCredential($user, $pw)
|
||||||
|
$emailMessage = New-Object System.Net.Mail.MailMessage
|
||||||
|
$emailMessage.From = new-object System.Net.Mail.MailAddress($user, "Backup ...")
|
||||||
|
$emailMessage.to.Add("RECEIVER@digimapas.cl")
|
||||||
|
$emailMessage.From = $user
|
||||||
|
$emailMessage.IsBodyHTML = $false
|
||||||
|
|
||||||
|
|
||||||
|
<#
|
||||||
|
to create readablity the email is formatted as html table
|
||||||
|
#>
|
||||||
|
$htmlEmailBody = ("Backup ...`n")
|
||||||
|
|
||||||
|
foreach($line in Get-Content $EmailAttachments) {
|
||||||
|
$htmlEmailBody += @($line)
|
||||||
|
$htmlEmailBody += @("`n")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($EmailAttachments.length -gt 0){
|
||||||
|
foreach($EmailAttachment in $EmailAttachments){
|
||||||
|
Write-Host $EmailAttachment
|
||||||
|
$emailMessage.Attachments.Add($EmailAttachment)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$emailMessage.Subject = "Backup Webservices DMCL"
|
||||||
|
$emailMessage.Body = "$htmlEmailBody"
|
||||||
|
$SMTPClient.Send($emailMessage)
|
||||||
|
|
Loading…
Reference in a new issue