summaryrefslogtreecommitdiff
path: root/backup2webdav-pistar
blob: abac569173a925f971dfc513702a28146fc82605 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash

PATH=/usr/bin:/bin:/usr/sbin:/sbin

FRVAL=0

AUTH='pi-star:wtfwtfwtf!'

for h in `cat /etc/backup-pistar | tr '\n' ' ' 2> /dev/null`
do
	hn=`echo $h | perl -pe 's/^([^\.]+)\..*$/$1/g'`

	FT="/tmp/$hn.zip"
	
	if [ -f $FT ]; then
	        echo "File $FT exists - incomplete run?"
	        exit 1
	fi

	F=`mktemp`
	
	mv $F $FT

	curl -s -d "action=download" -X POST --user $AUTH --output $FT http://$h/admin/config_backup.php
	RVAL=$?

	if [ $RVAL != 0 ]; then
		echo "Error pulling down from $h"
		rm $FT
		FRVAL=1
	else 

		rclone --bind=44.70.48.34 copy $FT nextcloud:/Backups/$hn/
		RVAL=$?

		if [ $RVAL != 0 ]; then
			echo "Error rsyncing $FT to nextcloud"
			FRVAL=1
		fi
	
		rm $FT
	fi
	
done

exit $FRVAL