Skip to content

Instantly share code, notes, and snippets.

@juanboterotech
Created January 5, 2024 04:05
Show Gist options
  • Save juanboterotech/b5f55c16744ef892187273d776ce287d to your computer and use it in GitHub Desktop.
Save juanboterotech/b5f55c16744ef892187273d776ce287d to your computer and use it in GitHub Desktop.
Backup your WordPress website
#!/bin/bash
# get current date
now = `date +"%Y-%m-%d"`
# copying WordPress files inside public_html folder
cd ~/public_html
tar -zcf "~/wordpress_$_now.tar.gz" wordpress_folder
# Database backup with mysqldump
# replace the <dbuser> and <dbpassword> with your database user credentials defined for WordPress site, without < and >
mysqldump -u <dbuser> –p <dbpassword> -h localhost database_name > "db_$_now.sql"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment