Last active
September 27, 2023 00:47
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # backup database | |
| mysqldump --opt --user=user --password=password --host=host.com database > file-dd-mm-yy.sql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # untar to public and remove containing directory | |
| tar -zxvf hh-backup.tar.gz -C public/ --strip-components=1 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On one Ubuntu setup I had to add origing at the end to make it work and I used double quotes