FreeBSD Bugzilla – Attachment 174614 Details for
Bug 212556
sysutils/tarsnap-periodic: Fix tarsnap-backup script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
PATCH tarsnap-backup script
patch-bin_tarsnap-backup (text/plain), 2.75 KB, created by
Jose Luis Duran
on 2016-09-10 08:05:16 UTC
(
hide
)
Description:
PATCH tarsnap-backup script
Filename:
MIME Type:
Creator:
Jose Luis Duran
Created:
2016-09-10 08:05:16 UTC
Size:
2.75 KB
patch
obsolete
>--- bin/tarsnap-backup.orig 2016-09-10 07:58:18 UTC >+++ bin/tarsnap-backup >@@ -3,7 +3,7 @@ > TARSNAP_CMD=/usr/local/bin/tarsnap > > path2name() { >- res=$(echo $1 | sed -E -e 's,/+,/,g' -e 's,/$|^/,,g' -e 's,/,-,g') >+ res=$(echo "$1" | sed -E -e 's,/+,/,g' -e 's,/$|^/,,g' -e 's,/,-,g') > if [ -z "$res" ]; then > res='ROOT' > fi >@@ -36,13 +36,13 @@ create_backup() > exit 1 > esac > >- fullname="$(path2name $path)-$now" >+ fullname="$(path2name "$path")-$now" > # look for an existing backup with this name > if $TARSNAP_CMD --list-archives | grep -q "^${fullname}$"; then > echo "* backup $fullname already exists, skipping..." > else > echo " * making backup: $fullname" >- $TARSNAP_CMD -c -f $fullname $path || something_wrong=1 >+ $TARSNAP_CMD -c -f "$fullname" "$path" || something_wrong=1 > fi > } > >@@ -51,7 +51,7 @@ delete_backup() > { > backup=$1 > echo " * deleting old backup: $backup" >- $TARSNAP_CMD -d -f $backup >+ $TARSNAP_CMD -d -f "$backup" > } > > # make a $type backup of path, cleaning up old ones >@@ -61,7 +61,7 @@ do_path() > keep=$2 > type=$3 > >- name="`path2name $path`" >+ name="$(path2name "$path")" > > # create the regex matching the type of backup we're currently working on > case "$type" in >@@ -86,23 +86,23 @@ do_path() > exit 1 > esac > >- create_backup $path $type >+ create_backup "$path" "$type" > > # get a list of all of the backups of this type sorted alpha, which > # effectively is increasing date/time >- backups=$($TARSNAP_CMD --list-archives | grep $regex | sort) >- count=$(echo $backups | wc -l) >- if [ $count -ge 0 ]; then >+ backups=$($TARSNAP_CMD --list-archives | grep "$regex" | sort) >+ count=$(echo "$backups" | wc -l) >+ if [ "$count" -ge 0 ]; then > # how many items should we delete >- delete=$(expr $count - $keep) >+ delete=$((count - keep)) > count=0 > # walk through the backups, deleting them until we've trimmed deleted > for backup in $backups; do > if [ $count -ge $delete ]; then > break > fi >- delete_backup $backup >- count=$(expr $count + 1) >+ delete_backup "$backup" >+ count=$((count + 1)) > done > fi > } >@@ -117,9 +117,9 @@ do_backups() > echo "" > echo "Doing tarsnap $type backups:" > for path in $paths; do >- do_path $path $keep $type >+ do_path "$path" "$keep" "$type" > done >- if [ -n something_wrong ]; then >+ if [ -n "$something_wrong" ]; then > exit 3 > fi > } >@@ -128,4 +128,4 @@ if [ $# -ne 3 ]; then > echo "Usage: $0 \"<paths>\" <keep> daily|weekly|monthly|yearly" > exit 2 > fi >-do_backups "$1" $2 $3 >+do_backups "$1" "$2" "$3"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 212556
:
174614
|
174648
|
174764
|
174765