Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matdombrock/wordpress-backup
https://github.com/matdombrock/wordpress-backup
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/matdombrock/wordpress-backup
- Owner: matdombrock
- License: mit
- Created: 2018-05-01T22:32:02.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T22:35:34.000Z (over 6 years ago)
- Last Synced: 2024-11-07T04:44:32.681Z (2 months ago)
- Language: Shell
- Size: 5.86 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WordPress Backup
## backup.sh
Automates WordPress backups from the CLI
```bash
#!/bin/bash
name= #used only for file names
#DB CONNECTION INFO
password=
db_name=
#config options
web_root=/var/www/html/
temp_output=/var/www/html/backup/ #one-time download backup location. Should be on web root.
output=/root/ #main backup location. Should not be avail to webroot.
touch ${temp_output}/index.html
read -p "Do you want to purge the old temporary backups? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
# do dangerous stuff
rm -R ${temp_output}/*
fi
t=$(date +%s)
d=$(date)
mkdir ${t}
touch ${t}/"${d}"
mysqldump --password="${password}" ${db_name} >> ${t}/${db_name}.sql
zip -r ${t}/files.zip ${web_root}* -x "${temp_output}*"
zip -r ${name}+${t}.zip ${t}/*
cp ${name}+${t}.zip ${temp_output}
cp ${name}+${t}.zip ${output}
rm -R ${t}
rm ${name}+${t}.zip
```
### USAGE:Edit the lines at the top to include the correct info.
Make it executable with:
```
chmod u+x backup.sh
```Run it with:
```
./backup.sh
```