Skip to content

Instantly share code, notes, and snippets.

@peteristhegreat
Last active February 8, 2023 20:22
Show Gist options
  • Save peteristhegreat/0be396183bf68c9f0a6fae7a389facf9 to your computer and use it in GitHub Desktop.
Save peteristhegreat/0be396183bf68c9f0a6fae7a389facf9 to your computer and use it in GitHub Desktop.
Diffing Directories, Folders, git, rsync, diff

One Liners to Diff Directories

diff --brief -Nr dir1/ dir2/
git diff --no-index dir1/ dir2/
git diff --stat --no-index dir1/ dir2/
diff <(ssh server1 'sudo ls -1aR /var/www/vhosts/domain.com') <(ssh server2 'sudo ls -1aR /var/www/vhosts/domain.com')
rsync --dry-run -rvc user@server1:/var/www/vhosts/ /var/www/vhosts/domain.com/

http://stackoverflow.com/questions/4997693/given-two-directory-trees-how-can-i-find-out-which-files-differ http://zuhaiblog.com/2011/02/14/using-diff-to-compare-folders-over-ssh-on-two-different-servers/

Rsync to Diff Directories

echo "RCS  SCCS  CVS  CVS.adm  RCSLOG  cvslog.* tags TAGS .make.state .nse_depinfo *~ #* .#* ,* _$* *$
*.old *.bak *.BAK *.orig *.rej .del-* *.a *.olb *.o *.obj *.so *.exe *.Z *.elc *.ln  core  .svn/
.git/ .bzr/" > $HOME/.cvsignore

echo "#list of folders and files to exclude in rsync
folder_to_ignore
file_to_ignore
another_file
" > /temp/exclude_list.txt
# rsync src/ dest/  # use trailing slashes to avoid confusion and bad stuff unless you know what you are doing.
# a - archive (recursive copy, preserve everything)
# v - verbose
# z - compress
# h - human-readable (uses K/M/G for file sizes)
# P - partial progress, helpful for long transfers
# C - csv-exclude, looks at the .csvignore file and skips those files types
# O - omit directory timestamps
# c - checksum, require content differences, not just timestamps or size
rsync --dry-run --exclude-from=/temp/exclude_list.txt -avzhPCOc local/path/ remote_server:remote/path/ | tee > /temp/rsync_output.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment