Revisions
-
bmarwell revised this gist
Oct 30, 2017 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ ## installing systemd services + timers systemctl daemon-reload systemctl enable btrfs-scrub.service systemctl enable btrfs-scrub.timer systemctl start btrfs-scrub.timer chmod 600 /root/.netrc apt-get install curl (if you are inside a in container) -
bmarwell revised this gist
Oct 30, 2017 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ machine smtp.gmail.com login user@gmail.com password my-app-password -
bmarwell revised this gist
Oct 30, 2017 . 3 changed files with 22 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,41 +12,44 @@ EMAIL_SUBJECT_PREFIX="$HOSTNAME BTRFS - " EMAIL_ADDRESS="<email@address>" LOG_FILE="/var/log/btrfs-scrub.log" TMP_OUTPUT="/tmp/btrfs-scrub.$$.out" # redirect all stdout to log gile exec >> $LOG_FILE echo "[`date -Iseconds`] btrfs scrub job started." # mail header to the file echo "From: "My Name" <$EMAIL_ADDRESS>" > $TMP_OUTPUT echo "To: "My Name" <$EMAIL_ADDRESS>" >> $TMP_OUTPUT echo "Subject: $EMAIL_SUBJECT_PREFIX Scrub Job Completed" >> $TMP_OUTPUT echo "" >> "$TMP_OUTPUT" # timestamp the job echo "[`date -Iseconds`] btrfs scrub job started." echo "btrfs scrub job started on `date -Iseconds`" >> $TMP_OUTPUT echo "----------------------------------------" >> $TMP_OUTPUT # for each btrfs type system mounted, scrub and record output while read d m t x do [[ $t != "btrfs" ]] && continue echo "scrubbing $m" >> $TMP_OUTPUT echo "[`date -Iseconds`] scrubbing $m" btrfs scrub start -Bd $m >> $TMP_OUTPUT echo "" >> $TMP_OUTPUT done </proc/mounts echo "----------------------------------------" >> $TMP_OUTPUT echo "btrfs scrub job finished on `date -Iseconds`" >> $TMP_OUTPUT curl \ --netrc --ssl-reqd \ --mail-from "<$EMAIL_ADDRESS>" \ --mail-rcpt "<$EMAIL_ADDRESS>" \ --url smtps://smtp.gmail.com:465 \ -T "$TMP_OUTPUT" \ && rm "$TMP_OUTPUT" || true echo "[`date -Iseconds`] Scrub job ended." exit 0; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,5 +2,6 @@ Description=btrfs scrub [Service] User=root Type=simple ExecStart=/usr/local/bin/btrfs-scrub This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ Description=Runs btrfs scrub on all discs monthly [Timer] OnCalendar=weekly [Install] WantedBy=timers.target -
gbrks revised this gist
Aug 15, 2015 . 2 changed files with 1 addition and 1 deletion.There are no files selected for viewing
File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,4 +3,4 @@ Description=btrfs scrub [Service] Type=simple ExecStart=/usr/local/bin/btrfs-scrub -
gbrks revised this gist
Aug 1, 2015 . 1 changed file with 14 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,12 @@ EMAIL_SUBJECT_PREFIX="$HOSTNAME BTRFS - " EMAIL_ADDRESS="<email@address>" #Mailgun API MG_API="api:key-<apikey>" MG_DOMAIN="<domain>" MG_FROM="<email_from>" LOG_FILE="/var/log/btrfs-scrub.log" TMP_OUTPUT="/tmp/btrfs-scrub.out" @@ -33,7 +39,14 @@ done </proc/mounts echo "----------------------------------------" >> $TMP_OUTPUT echo "btrfs scrub job finished on `date`" >> $TMP_OUTPUT curl -s --user "$MG_API" \ https://api.mailgun.net/v3/$MG_DOMAIN/messages \ -F from="$MG_FROM" \ -F to="$EMAIL_ADDRESS" \ -F subject="$EMAIL_SUBJECT_PREFIX Scrub Job Completed" \ -F text="$(cat $TMP_OUTPUT)" \ echo "[`date`] Scrub job ended." exit 0; -
gbrks revised this gist
May 16, 2015 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ [Unit] Description=btrfs scrub [Service] Type=simple ExecStart=/root/scripts/btrfs-scrub.sh -
gbrks revised this gist
May 16, 2015 . 1 changed file with 0 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +0,0 @@ -
gbrks revised this gist
May 16, 2015 . 2 changed files with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ [Unit] Description=btrfs scrub [Service] Type=simple ExecStart=/root/scripts/btrfs-scrub.sh This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ [Unit] Description=Runs btrfs scrub on all discs monthly [Timer] OnCalendar=monthly [Install] WantedBy=timers.target -
gbrks created this gist
May 16, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #! /bin/bash ####################################################### # This is a helper script to be used in a systemd timer # or cron job to scrub all mounted btrfs filessytems # # $Author: gbrks # $Revision 0.1 # $Date: 2015.05.15 # # Update email address below EMAIL_SUBJECT_PREFIX="$HOSTNAME BTRFS - " EMAIL_ADDRESS="<email@address>" LOG_FILE="/var/log/btrfs-scrub.log" TMP_OUTPUT="/tmp/btrfs-scrub.out" # redirect all stdout to log gile exec >> $LOG_FILE # timestamp the job echo "[`date`] btrfs scrub job started." echo "btrfs scrub job started on `date`" > $TMP_OUTPUT echo "----------------------------------------" >> $TMP_OUTPUT # for each btrfs type system mounted, scrub and record output while read d m t x do [[ $t != "btrfs" ]] && continue echo "scrubbing $m" >> $TMP_OUTPUT echo "[`date`] scrubbing $m" btrfs scrub start -Bd $m >> $TMP_OUTPUT echo "" >> $TMP_OUTPUT done </proc/mounts echo "----------------------------------------" >> $TMP_OUTPUT echo "btrfs scrub job finished on `date`" >> $TMP_OUTPUT /usr/bin/mail -s "$EMAIL_SUBJECT_PREFIX Scrub Job Completed" "$EMAIL_ADDRESS" < $TMP_OUTPUT echo "[`date`] Scrub job ended." exit 0;