RF Eclectica Wiki

Try to learn something about everything, and everything about something - Thomas Huxley

User Tools

Site Tools


Github Config File Repos

John Pumford-Green Tue May 3 20:09:19 2022

  1. New GitHub account https://github.com/gm4slv
  2. Upload ssh ip_rsa.pub to Git account
  3. create GitHub repository for each machine (more later)
  4. Create a “backup” folder hierarchy ~/backup/config/, ~/backup/data/ and ~/backup/bin/
  5. create Git repository in the ~/backup/data/ directory
  6. put script in ~/backup/bin/copy_files.sh

Inspired by : https://helgeklein.com/blog/linux-config-file-version-control-backup-on-github/

# 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 % ."
  1. put list of files to be git-backed up in ~/backup/config/backup_src.txt
  1. put another script ~/git_backup.sh in home directory, to fire it all off in the correct order
DATE=`date +%c`
cd ~/backup/data
git add --all
git commit -m "updated $DATE"
git push

Page Updated : 05/05/22 18:12 BST

public/computers/github.txt · Last modified: 05/05/22 18:12 BST by