Skip to content

Commit

Permalink
Merge pull request #40 from kjetilmjos/dev
Browse files Browse the repository at this point in the history
empty file issue fix
  • Loading branch information
kjetilmjos authored Jul 17, 2023
2 parents 9554d17 + 9667c6e commit 96c8777
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2023.6.9
- Fixed issue with empty file when starting first time
-
## 2023.6.8

- Created know hosts file using touch
Expand Down
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "m-connect"
description: "Wireguard client for reverse proxy in cloud setup"
version: "2023.6.8"
version: "2023.6.9"
slug: "m_connect"
init: false
url: https://github.com/kjetilmjos/m-connect
Expand Down
14 changes: 9 additions & 5 deletions rootfs/etc/s6-overlay/s6-rc.d/backup/run
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,26 @@ fi

# Turn off "exit on error" option
set +e
fileinfo=$(ssh "$USERNAME@$m_cloud_server_ip" -i "/data/backup_cred/$USERNAME" stat -c %y "/m-connect/$USERNAME/$USERNAME.tar")
if [ ssh "$USERNAME@$m_cloud_server_ip" -i "/data/backup_cred/$USERNAME" -f "/m-connect/$USERNAME/$USERNAME.tar" ]; then
bashio::log.info "File exists"
fileinfo=$(ssh "$USERNAME@$m_cloud_server_ip" -i "/data/backup_cred/$USERNAME" stat -c %y "/m-connect/$USERNAME/$USERNAME.tar")
else
bashio::log.info "File does NOT exists, new backup will be uploaded"
fileinfo="2000-00-00 12:00:00.000000000 +0000"
fi

# Turn on "exit on error" option
set -e
newdate=$(date -d "$fileinfo" +%s)

# Check the file on the m-cloud server. If it's newer than the backup intervall exit the script and try again after the delay.
if [ $? -ne 0 ]; then
bashio::log.warning "Remote backup file not found on m-cloud server. There could be an error or this is the first time the backup script is started."
else
bashio::log.info "Timestamp of backup file stored on m-cloud server: $fileinfo"
if [ $TARGET_TIMESTAMP -lt $newdate ]; then
bashio::log.info "File on m-cloud server is newer than backup creation target. Script will sleep for one day and check again"
sleep 1d
bashio::exit.ok
else
bashio::log.info "File on m-cloud server is not newer than backup creation target. A new one should be created."
bashio::log.info "File on m-cloud server is NOT newer than backup creation target. A new one should be created."
fi
fi

Expand Down

0 comments on commit 96c8777

Please sign in to comment.