-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.sh
executable file
·38 lines (30 loc) · 1.26 KB
/
git.sh
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
#!/bin/bash
# Git Script
# Executd from the Gateway
# Copies the datalogger data to local Git repositories and then stages them and pushes them to the remote Git repository.
# Usage: Add the following line to crontab to run it every 6 hours:
# 00 /6 * * * git.sh
dataloggerdir=/data/CR3000Data
logfile=/data/carina-logs/git.log
datadir=/data/carina-data
logdir=/data/carina-logs
timestamp=$(date +"%D %T %Z %z")
echo -e "\n\n#################################################################\n" 2>&1 | tee -a $logfile
echo -e "############## $HOSTNAME - $timestamp ##############" 2>&1 | tee -a $logfile
echo -e "\n#################################################################\n\n" 2>&1 | tee -a $logfile
echo -e "GitHub:\n" 2>&1 | tee -a $logfile
cd $datadir
git pull 2>&1 | tee -a $logfile
cp -rf $dataloggerdir/* $datadir
git add . 2>&1 | tee -a $logfile
git commit -m "$timestamp: Git Backup" 2>&1 | tee -a $logfile
git push 2>&1 | tee -a $logfile
echo -e "\n\nGateway:\n" 2>&1 | tee -a $logfile
cd $logdir
git pull 2>&1 | tee -a $logfile
git add . 2>&1 | tee -a $logfile
git commit -m "$timestamp: Logs" 2>&1 | tee -a $logfile
git push &>> $logfile
git add . 2>&1 | tee -a $logfile
git commit -m "$timestamp: Logs" 2>&1 | tee -a $logfile
git push 2>&1 | tee -a $logfile