Skip to content

Instantly share code, notes, and snippets.

@jasperf
Last active September 27, 2023 00:47
Show Gist options
  • Select an option

  • Save jasperf/6395798 to your computer and use it in GitHub Desktop.

Select an option

Save jasperf/6395798 to your computer and use it in GitHub Desktop.
Backup your site's files using tar and gzip from the command line. #tar #gzip #backup
# backup database
mysqldump --opt --user=user --password=password --host=host.com database > file-dd-mm-yy.sql
## No dash "-" with this order destination origin and on gnu os like DH Ubuntu
## http://unix.stackexchange.com/questions/13573/why-use-superflous-dash-to-pass-option-flags-to-tar
## Destination - origin unlike scp
tar cvzf sitecom.tar.gz directoryname
## And to empty directory
rm -r /path/to/directory/*
## And to exclude a directory while backing up use
## Make sure not to add a trailing slash!
tar cvzf site.com.tar.gz site.com/ --exclude=site.com/wp-content/uploads/backupbuddy_backups
# untar to public and remove containing directory
tar -zxvf hh-backup.tar.gz -C public/ --strip-components=1
@jasperf
Copy link
Author

jasperf commented Jul 12, 2021

On one Ubuntu setup I had to add origing at the end to make it work and I used double quotes

tar cvzf site.com.tar.gz --exclude="htdocs/old/*" --exclude="htdocs/wp-content/ai1wm-backups/*" htdocs/

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