jcoffey-dev 1e676bb634 Make backup and restore safe to actually rely on
backup.sh named archives with %Y%m%d, so a second run on the same day
silently overwrote the first -- destroying a good backup at the moment
someone was trying to take another. Names now carry seconds, and an
existing path is refused rather than clobbered. The archive is also
written to a .partial name and renamed only on success, with a trap to
clean up, so an interrupted run cannot leave a truncated file that looks
like a backup.

restore.sh extracted with tar's defaults. An archive is untrusted input
-- whoever produced it chooses the paths, ownership and modes inside it
-- and extracting as root let the tarball dictate uid/gid and restore
setuid bits directly. Now --no-same-owner --no-same-permissions, with -P
still absent so tar keeps stripping leading "/" and refusing ".."
members. It also lists what it is about to extract and confirms first,
since it silently overwrote whatever was already in the target.

Both scripts also gained set -euo pipefail, and both replaced the
`cmd; if [ $? -eq 0 ]` pattern with a direct `if cmd; then`, which is
what that idiom was reaching for and gets wrong as soon as any command
is inserted between the two lines.

Verified end to end: two same-second-apart backups both survive, no
.partial residue, restore refuses non-interactively, and the round trip
diffs identical.
2026-08-22 22:20:04 -07:00
2025-05-17 10:06:21 -07:00
2025-05-17 10:06:49 -07:00
2025-06-12 16:03:33 -07:00
2025-05-17 10:06:49 -07:00
2025-05-17 10:06:49 -07:00
2025-05-17 10:06:49 -07:00

Linux System Administration Scripts

Automate routine tasks: This project provides a collection of Bash scripts to automate common Linux system administration duties. Automating daily sysadmin tasks improves efficiency and consistency by reducing manual repetition and the risk of human error. Each script is designed to be distribution-agnostic, using only standard base utilities (e.g. rsync, tar, awk, grep, netstat/ss, systemctl) available on most Linux systems. All scripts are released under the GNU GPL v3.0 license and include usage information in their headers.

Included Scripts

  • backup.sh Backup Utility: Archive directories into compressed tarballs for backups.
  • restore.sh Restore Utility: Restore files from backup archives.
  • disk_cleanup.sh Disk Usage & Cleanup: Report disk usage and identify large files; optionally clean package caches and temporary files to free space.
  • log_inspect.sh Log Inspection: Search within log files or tail the latest system logs for troubleshooting.
  • log_rotate.sh Log Rotation: Compress and rotate old log files to prevent excessive disk usage
  • network_info.sh Network & Firewall Info: Show network interface details, routing table, open listening ports, and basic firewall (iptables) rules.
  • process_monitor.sh Process Management: List top resource-consuming processes and allow termination of processes by name or PID.
  • security_audit.sh Security Audit: Scan for security issues like world-writable files, SUID/SGID executables, and open network ports.
  • service_manager.sh Service Management: Start, stop, restart, or check status of system services, and enable/disable services at boot.
  • sys_monitor.sh System Monitoring: Display system uptime, resource utilization (CPU, memory, disk), and top processes.
  • update_system.sh System Updates: Apply available package updates and patches (works with apt, yum/dnf, zypper, pacman).
  • user_manage.sh User and Group Management: Create or remove user accounts and groups, modify user group memberships, and lock/unlock accounts.
  • zimbra_backup.sh - Create a backup for a zimbra mailbox.
  • zimbra_restore.sh - Restore a backup for a zimbra mailbox.
  • rsync_magic.sh - A smart Bash script that wraps rsync for safe, flexible, and efficient file synchronization and backups.
S
Description
Imported from github.com during the 2026-09-20 standup (local dir: SysAdminAutomation)
Readme GPL-3.0
106 KiB
Languages
Shell 100%