Skip to content

Commit d44e6f0

Browse files
authored
Create backup.sh
1 parent 2c722d3 commit d44e6f0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

backup.sh

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
DIRNAME=/var/www/html/project
4+
ARCHIVE=backup_$(date +%Y_%m_%d)
5+
DBUSER=root
6+
DBPASSWORD=password
7+
DBNAME=project
8+
9+
10+
echo "dumping database ..."
11+
12+
mysqldump -u ${DBUSER} -p"${DBPASSWORD}" ${DBNAME} > "${DIRNAME}/dump.sql"
13+
14+
echo "zip archive ..."
15+
16+
tar -czf "${ARCHIVE}.tar.gz" ${DIRNAME}/ --exclude="${DIRNAME}/node_modules" --exclude="${DIRNAME}/vendor" --exclude="${DIRNAME}/.git" --exclude="${DIRNAME}/.idea" --exclude="${DIRNAME}/storage/logs/*"
17+
18+
rm "${DIRNAME}/dump.sql"
19+
20+
21+
echo "success"

0 commit comments

Comments
 (0)