====== Github Config File Repos ====== //[[gm4slv@gm4slv.plus.com|John Pumford-Green]] Tue May 3 20:09:19 2022// - New GitHub account [[https://github.com/gm4slv]] - Upload ssh ip_rsa.pub to Git account - create GitHub repository for each machine (more later) - Create a "backup" folder hierarchy ''~/backup/config/'', ''~/backup/data/'' and ''~/backup/bin/'' - create Git repository in the ''~/backup/data/'' directory - put script in ''~/backup/bin/copy_files.sh'' Inspired by : [[https://helgeklein.com/blog/linux-config-file-version-control-backup-on-github/]] #!/bin/bash # Remove all previously copied files and folders (excluding metadata) in the current (backup) directory find /home/gm4slv/backup/data -maxdepth 1 -mindepth 1 -not -iname ".git" -not -iname ".ssh" | xargs --no-run-if-empty rm -r # Copy the files and directories on the list to the current (backup) directory # xargs does not start a shell, so we need to do it ourselves or globbing won't be available # Enable globstar (two asterisks = recurse into subdirectories) and include files starting with a dot in filename expansion cat /home/gm4slv/backup/config/backup_src.txt | xargs -I % bash -c "shopt -s globstar dotglob; cp --parents -R % ." - put list of files to be git-backed up in ''~/backup/config/backup_src.txt'' /etc/hosts /etc/resolv.conf /home/gm4slv/codeplugs/ /home/gm4slv/python_lost_found/ - put another script ''~/git_backup.sh'' in home directory, to fire it all off in the correct order #!/bin/bash # DATE=`date +%c` cd ~/backup/data ../bin/copy_files.sh git add --all git commit -m "updated $DATE" git push Page Updated : ~~LASTMOD~~ {{tag>github linux}}