summaryrefslogtreecommitdiff
path: root/update.sh
diff options
context:
space:
mode:
Diffstat (limited to 'update.sh')
-rwxr-xr-xupdate.sh46
1 files changed, 23 insertions, 23 deletions
diff --git a/update.sh b/update.sh
index 6bc6de8..2b21a77 100755
--- a/update.sh
+++ b/update.sh
@@ -36,23 +36,23 @@ check_permissions() {
backup_configs() {
local install_type="$1"
local backup_dir
-
+
if [ "$install_type" = "system" ]; then
backup_dir="/etc/restic/backup-$(date +%Y%m%d-%H%M%S)"
sudo mkdir -p "$backup_dir"
- else
+ else
backup_dir="$HOME/.config/restic/backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir"
fi
-
+
log "Backing up configuration to $backup_dir"
-
+
if [ "$install_type" = "system" ]; then
sudo cp -r /etc/restic/* "$backup_dir/" 2>/dev/null || true
- else
+ else
cp -r "$HOME/.config/restic"/* "$backup_dir/" 2>/dev/null || true
fi
-
+
echo "$backup_dir"
}
@@ -60,7 +60,7 @@ backup_configs() {
update_scripts() {
local install_type="$1"
local install_dir
-
+
if [ "$install_type" = "system" ]; then
install_dir="/usr/local/bin"
log "Updating scripts in $install_dir"
@@ -83,7 +83,7 @@ update_scripts() {
update_services() {
local install_type="$1"
local systemd_dir
-
+
if [ "$install_type" = "system" ]; then
systemd_dir="/etc/systemd/system"
log "Updating systemd services in $systemd_dir"
@@ -104,13 +104,13 @@ update_services() {
update_bandwidth() {
local install_type="$1"
local env_file
-
+
if [ "$install_type" = "system" ]; then
env_file="/root/.restic_env"
else
env_file="$HOME/.config/restic/env"
fi
-
+
# Check if file exists and has old bandwidth setting
if [ -f "$env_file" ] && grep -q "RCLONE_BWLIMIT=1M" "$env_file"; then
log "Updating rclone bandwidth limit from 1M to 2M"
@@ -125,7 +125,7 @@ update_bandwidth() {
# Restart services
restart_services() {
local install_type="$1"
-
+
log "Restarting systemd timers"
if [ "$install_type" = "system" ]; then
sudo systemctl restart restic-backup.timer restic-check.timer
@@ -141,39 +141,39 @@ restart_services() {
# Main update logic
main() {
log "Starting drestic update process"
-
+
# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
-
+
# Check we're in a git repo
- if ! git rev-parse --git-dir > /dev/null 2>&1; then
+ if ! git rev-parse --git-dir >/dev/null 2>&1; then
error "Not in a git repository. Please run from drestic directory."
fi
-
+
# Detect installation type
install_type=$(detect_installation)
log "Detected $install_type installation"
-
+
# Check permissions
check_permissions "$install_type"
-
+
# Backup configs
backup_dir=$(backup_configs "$install_type")
log "Configuration backed up to: $backup_dir"
-
+
# Update scripts
update_scripts "$install_type"
-
+
# Update services
update_services "$install_type"
-
+
# Update bandwidth (optional)
update_bandwidth "$install_type"
-
+
# Restart services
restart_services "$install_type"
-
+
log "Update completed successfully!"
echo ""
echo "Key improvements in this update:"
@@ -186,4 +186,4 @@ main() {
}
# Run main function
-main "$@" \ No newline at end of file
+main "$@"