Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some initial replication framework

  • Loading branch information...
commit 4e5ccedaed1935a672d6918ff7c90d3c2e030b73 1 parent e674d0b
@kmoore134 kmoore134 authored
View
40 src-sh/lpreserver/backend/functions.sh
@@ -13,8 +13,9 @@ PROGDIR="/usr/local/share/lpreserver"
DBDIR="/var/db/lpreserver"
if [ ! -d "$DBDIR" ] ; then mkdir -p ${DBDIR} ; fi
CMDLOG="${DBDIR}/lp-lastcmdout"
+REPCONF="${DBDIR}/replication"
LOGDIR="/var/log"
-export DBDIR LOGDIR PROGDIR CMDLOG
+export DBDIR LOGDIR PROGDIR CMDLOG REPCONF
MSGQUEUE=""
export MSGQUEUE
@@ -149,3 +150,40 @@ queue_msg() {
echo_queue_msg() {
echo -e "$MSGQUEUE"
}
+
+add_rep_task() {
+ # add freenas.8343 backupuser 22 tank1/usr/home/kris tankbackup/backups sync
+ HOST=$1
+ USER=$2
+ PORT=$3
+ LDATA=$4
+ RDATA=$5
+ TIME=$6
+
+ case $TIME in
+ [0-9][0-9]|sync) ;;
+ *) exit_err "Invalid time: $TIME"
+ esac
+
+ echo "Adding replication task for local dataset $LDATA"
+ echo "----------------------------------------------------------"
+ echo " Remote Host: $HOST"
+ echo " Remote User: $USER"
+ echo " Remote Port: $PORT"
+ echo "Remote Dataset: $RDATA"
+ echo " Time: $TIME"
+ echo "----------------------------------------------------------"
+ echo "Don't forget to ensure that this user / dataset exists on the remote host"
+ echo "with the correct permissions!"
+
+ rem_rep_task "$LDATA"
+ echo "$LDATA:$TIME:$HOST:$USER:$PORT:$RDATA" >> ${REPCONF}
+
+}
+
+rem_rep_task() {
+ if [ ! -e "$REPCONF" ] ; then return ; fi
+ cat ${REPCONF} | grep -v "^${1}:" > ${REPCONF}.tmp
+ mv ${REPCONF}.tmp ${REPCONF}
+}
+
View
21 src-sh/lpreserver/lpreserver
@@ -88,9 +88,9 @@ Add Options:
Remove Options:
- remove <id>
+ remove <dataset>
- Remove a replication task indicated by <id>
+ Remove a replication task indicated by <dataset>
Use 'replicate list' for a list of IDs.
Usage:
@@ -370,7 +370,22 @@ revertsnap) require_root
SNAP="$3"
${PROGDIR}/backend/zfsrmsnap.sh "${DATASET}" "${SNAP}"
;;
-
+ replicate) require_root
+ shift
+ case ${1} in
+ add) add_rep_task "$2" "$3" "$4" "$5" "$6" "$7" ;;
+ list) ;;
+ remove) cat ${REPCONF} | grep -q "^${2}:"
+ if [ $? -eq 0 ] ; then
+ rem_rep_task "$2"
+ echo "Removed replication task for $2"
+ else
+ exit_err "No such replication task for dataset $2"
+ fi
+ ;;
+ *) exit_err "Invalid option!" ;;
+ esac
+ ;;
*) help_main ;;
esac
Please sign in to comment.
Something went wrong with that request. Please try again.