summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbackup_personal60
-rwxr-xr-xbackup_personal_new68
-rwxr-xr-xbackup_simple54
-rwxr-xr-xsyncdata11
4 files changed, 9 insertions, 184 deletions
diff --git a/backup_personal b/backup_personal
deleted file mode 100755
index b196533..0000000
--- a/backup_personal
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/bash
-#backup_personal
-#this script backs up personal documents to the vps and personal server
-
-echo -e "backing up files $(date) \n" >> ~/.backuplog
-
-excluded=''
-src=''
-force=0
-excluded_list=""
-rsync_args=""
-ip='hb'
-home="/home/thomas/"
-user="thomas"
-
-while getopts ":x:p:f:l:d:" opt; do
- case $opt in
- x)
- echo "excluding files/dirs $OPTARG"
- excluded="$OPTARG"
- rsync_args=$rsync_args"--exclude $OPTARG "
- ;;
- l)
- echo "exluding files/dirs from list from file $OPTARG"
- excluded_list="\"$OPTARG\""
- rsync_args=$rsync_args"--exclude-from $OPTARG "
- ;;
- p)
- echo "backing up path $OPTARG"
- src="$OPTARG"
- ;;
- f)
- echo "forcing backup of entire home dir.\n"
- force=1
- ;;
- d)
- echo "destination address = $OPTARG"
- ip="$OPTARG"
- ;;
- esac
-done
-
-echo $rsync_args
-
-if [ -z "$src" ]
-then
- if [[ $force == 1 ]]
- then
- echo "-f set, so will backup entire home dir.\n"
- rsync -avzpR -e ssh ${home}/ ${user}@${ip}:backup | tee -a ~/.backuplog
- else
- echo "no custom path given. will do nothing.\n"
- exit 0
- fi
-else
- #rsync -avzp -e ssh --exclude-from "$excluded_list" --exclude $excluded /home/thomas/$src/ thomas@grothe.ddns.net:backup/$src | tee -a ~/.backuplog
- rsync -avzpP --relative -e ssh $rsync_args ${home}/./${src}/ ${user}@${ip}:${HB_BACKUP_DIR} | tee -a ~/.backuplog
-fi
-
-
diff --git a/backup_personal_new b/backup_personal_new
deleted file mode 100755
index 0453b5e..0000000
--- a/backup_personal_new
+++ /dev/null
@@ -1,68 +0,0 @@
-#!/bin/bash
-#backup_personal_new
-#this script backs up personal documents to personal server or any specified source
-
-
-echo -e "backing up files $(date) \n" >> ~/.backuplog
-
-#required args:
-# [src] - folder/file to backup
-#optional args:
-# [dest hostname] - (hb) hostname/ip of server to backup to
-# [x - exlude files matching pattern
-# [xf] - exlude files matching patterns from file
-# []
-
-
-excluded=''
-src=''
-force=0
-excluded_list=""
-rsync_args=""
-ip='grothe.ddns.net'
-
-while getopts ":x:p:f:l:d:" opt; do
- case $opt in
- x)
- echo "excluding files/dirs $OPTARG"
- excluded="$OPTARG"
- rsync_args=$rsync_args"--exclude $OPTARG "
- ;;
- l)
- echo "exluding files/dirs from list from file $OPTARG"
- excluded_list="\"$OPTARG\""
- rsync_args=$rsync_args"--exclude-from $OPTARG "
- ;;
- p)
- echo "backing up path $OPTARG"
- src="$OPTARG"
- ;;
- f)
- echo "forcing backup of entire home dir.\n"
- force=1
- ;;
- d)
- echo "destination address = $OPTARG"
- ip="$OPTARG"
- ;;
- esac
-done
-
-echo $rsync_args
-
-if [ -z "$src" ]
-then
- if [[ $force == 1 ]]
- then
- echo "-f set, so will backup entire home dir.\n"
- rsync -avzpR -e ssh /home/thomas/ thomas@"$ip":backup | tee -a ~/.backuplog
- else
- echo "no custom path given. will do nothing.\n"
- exit 0
- fi
-else
- #rsync -avzp -e ssh --exclude-from "$excluded_list" --exclude $excluded /home/thomas/$src/ thomas@grothe.ddns.net:backup/$src | tee -a ~/.backuplog
- rsync -avzpP --relative -e ssh $rsync_args /home/thomas/./$src/ thomas@"$ip":backup/ | tee -a ~/.backuplog
-fi
-
-
diff --git a/backup_simple b/backup_simple
deleted file mode 100755
index 72b2a3c..0000000
--- a/backup_simple
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/bash
-
-#a simple backup script that uses rsync
-
-#arg 1: source path: the path to backup.
-#arg 2 (optional): destination path: absolute path on host to put src
-#arg 3: rsync args
-#if no destination given, src will be pushed to the given src inside of path described by ${HB_BACKUP_DIR} env var, if it exists, otherwise it will be inside of remote user's home dir
-
-d=`date +%Y-%m-%d_%H:%M:%S`
-
-if [[ -z $1 ]]; then
- echo 'you must at least provide a source dir'
- exit 0
-fi
-
-src_path="$1"
-#dest='hb:/var/stor/personal/backup/'
-dest_host="hb"
-if [[ $HB_BACKUP_DIR ]]; then
- dest_path=$HB_BACKUP_DIR"/"
-else
- dest_path="~/"
-fi
-
-rsargs=''
-
-if [[ $2 ]]; then
- echo 'using destination '${2}
- dest_path=${2}
-fi
-
-if [[ $3 ]]; then
- shift 2
- rsargs=${@}
-fi
-
-dest=$dest_host":"$dest_path
-#if [[ ${dest_path: -1} == "/" ]]; then
-# ssh hb mkdir -p ${dest_path}
-#else
-# dest_parent_dir=`echo $dest_path | rev | cut -d'/' -f2- | rev`
-# ssh hb mkdir -p ${dest_parent_dir}
-#fi
-echo "NEW BACKUP $d ${src_path} -> ${dest}" >> /var/log/datasync.log
-rsync -ahAvz --protect-args -e ssh --update ${src_path} ${dest} ${rsargs} >> /var/log/datasync.log
-echo "" >> /var/log/datasync.log
-
-
-#if [[ TODO "%"` ]]; then
-# echo "Complete."
-#else
-# echo "!! ${src} not uploaded. Server version is newer."
-#fi
diff --git a/syncdata b/syncdata
index a0e1db0..a41663c 100755
--- a/syncdata
+++ b/syncdata
@@ -2,6 +2,11 @@
#TODO update: each folder has some metadata file in it to describe which folders to [in/ex]clude, and maybe some other rules. this metadata should either be in the filesystem itself or stored in a DB
+CONFIGFILE=`realpath ~/.config/datasync/files`
+DEST_HOST="hb" #destination host machine where we want to backup files to
+ #todo what is the assumed file layout on this host?
+ #todo add support for multiple destinations
+
if [[ $1 ]]; then
DBG=1
echo "DEBUG MODE :) yeeee"
@@ -14,11 +19,13 @@ if [[ $statuscheck == *onnect* ]]; then
fi
#backs up commonly modified files
-for f in `cat ~/.config/datasync/files`; do
+for f in `cat ${CONFIGFILE}`; do
if [[ ${f:0:1} == '#' ]]; then
continue
fi
- f=`echo ${f} | sed 's,~,/home/'${USER}',g'`
+ #f=`echo ${f} | sed 's,~,/home/'${USER}',g'`
+ f=`realpath ${f}`
+
if [[ $DBG ]]; then
echo "file: "$f
fi