Skip to content

Instantly share code, notes, and snippets.

@sbamin
Created February 12, 2017 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sbamin/31d16f9c889556c43f5f068e2b3ff1e6 to your computer and use it in GitHub Desktop.
Save sbamin/31d16f9c889556c43f5f068e2b3ff1e6 to your computer and use it in GitHub Desktop.
How to rsync dot files and directories of remote server

backup dotfiles

  • Following will copy all of dot ~/. files and directories (including its contents) directly underneath home directory.
  • To avoid copying cache and other local configs, e.g., that of web browser, java apps, etc., preferably query directory size tool under entire home $HOME/, using ncdu $HOME of similar tool.
  • Exclude all those large directories using rsync --exclude=.local --exclude=.cache format
  • Avoid rsync password, ssh keys, .bash_history, etc. if you are uploading to github, etc.
  • rsync home dotfiles and configs as follows:
# in your local machine
mkdir -p ~/server_dotfiles

# let's say your server name is tomtom, then execute rsync command as follows from your local machine. You can add/remove dot files and/or directories you like to exclude using --exclude option

rsync -avhP --exclude=".aspera" --exclude=".autojump" --exclude=".bash_history" --exclude=".bash_logout" --exclude=".cache" --exclude=".continuum" --exclude=".gem" --exclude=".gnome2" --exclude=".local" --exclude=".mozilla" --exclude=".myconfigs" --exclude=".oracle_jre_usage" --exclude=".parallel" --exclude=".pki" --exclude=".rbenv" --exclude=".Rhistory" --exclude=".rstudio" --exclude=".ssh" --exclude=".subversion" tomtom:.[^.]* ~/server_dotfiles/

END

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