Skip to content

Instantly share code, notes, and snippets.

@amigus
Last active May 15, 2022 05:08
Show Gist options
  • Save amigus/ae59a8b57de3b19949992a995b97f8de to your computer and use it in GitHub Desktop.
Save amigus/ae59a8b57de3b19949992a995b97f8de to your computer and use it in GitHub Desktop.
A script that creates a script that backs up the '/etc' folder. To use it, run `/etc/bak` after running the script below, as root.
#!/bin/sh
cat<<EOF>>/etc/bak.exclude
./etc/.pwd.lock
./etc/machine-id
./etc/mtab
./etc/multipath/bindings
./etc/openldap/schema
./etc/os-release
./etc/resolv.conf
./etc/ssh/ssh_host_*
EOF
cat<<EOF>>/etc/bak.include
./etc
./root/.ssh/authorized_keys
./var/lib/letsencrypt
EOF
cat<<EOF>>/etc/bak
#!/bin/sh
bak=/bak.\$(date -I).tar.gz
tar -C / -acpf \${1:-\${bak}} --exclude-from=/etc/bak.exclude --files-from=/etc/bak.include
EOF
chmod +x /etc/bak
@amigus
Copy link
Author

amigus commented Apr 15, 2022

I use this to save and clone my Clear Linux machines. The 'exclude' files are typical Clear Linux files that I want to drop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment