summaryrefslogtreecommitdiff
path: root/uninstall_system.sh
blob: 1f217e616dc97b1c201e60dd661b84bf34165b9a (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -euo pipefail

echo "=== DRestic System Scope Uninstall ==="
echo "WARNING: This will remove DRestic system installation"
echo ""

# Check for root privileges
if [ "$EUID" -ne 0 ]; then
	echo "Error: System scope uninstall requires root privileges."
	echo "Please run: sudo $0"
	exit 1
fi

# Confirmation
read -p "Continue with system uninstall? [y/N] " confirm
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
	echo "Uninstall cancelled."
	exit 0
fi

echo "Stopping and disabling systemd timers..."
systemctl stop restic-backup.timer restic-check.timer 2>/dev/null || true
systemctl disable restic-backup.timer restic-check.timer 2>/dev/null || true

echo "Removing systemd service and timer files..."
rm -f /etc/systemd/system/restic-backup.service
rm -f /etc/systemd/system/restic-backup.timer
rm -f /etc/systemd/system/restic-check.service
rm -f /etc/systemd/system/restic-check.timer

echo "Reloading systemd daemon..."
systemctl daemon-reload

echo "Removing backup scripts..."
rm -f /usr/local/bin/restic_backup.sh
rm -f /usr/local/bin/restic_check.sh

echo ""
echo "Remove configuration files? This includes passwords and settings!"
echo "Your backup data in MEGA will remain safe."
read -p "Remove /etc/restic/ and /root/.restic_*? [y/N] " config_confirm

if [ "$config_confirm" = "y" ] || [ "$config_confirm" = "Y" ]; then
	echo "Removing configuration files..."
	rm -rf /etc/restic/
	rm -f /root/.restic_*
	echo "Configuration removed."
else
	echo "Configuration kept at /etc/restic/ and /root/.restic_*"
fi

echo ""
echo "✓ DRestic system scope uninstall completed!"
echo "• Systemd timers stopped and disabled"
echo "• Scripts removed from /usr/local/bin/"
echo "• Systemd files removed"
if [ "$config_confirm" = "y" ] || [ "$config_confirm" = "Y" ]; then
	echo "• Configuration removed"
else
	echo "• Configuration preserved"
fi
echo "• Backup data remains safe in MEGA"
echo ""
echo "To remove backup data from MEGA, use:"
echo "  rclone purge backup_remote:/restic_backups"
echo "  rclone config delete backup_remote"