ajout du système de backup
This commit is contained in:
parent
3d7ab485db
commit
dbb04e66af
12
README.md
12
README.md
|
|
@ -44,8 +44,9 @@ Tested and optimised for [OVH VPS Starter](https://www.ovhcloud.com/fr/vps/cheap
|
|||
8. Install Node
|
||||
9. Prompt for the url
|
||||
10. Install and run Directus
|
||||
11. Install and run the front-end
|
||||
12. Setup a webhook
|
||||
11. Setup backup
|
||||
12. Install and run the front-end
|
||||
13. Setup a webhook
|
||||
|
||||
## Post-install
|
||||
|
||||
|
|
@ -76,6 +77,13 @@ Branch filter prod
|
|||
Authorization Header generate a safe string using : openssl rand -base64 32
|
||||
```
|
||||
|
||||
4. Setup Matomo tracking
|
||||
|
||||
Add a new website to track from the Matomo interface as an admin user
|
||||
|
||||
All website → Add a new Website → Website
|
||||
|
||||
|
||||
## Ref
|
||||
|
||||
[Debian Web Server](https://figureslibres.io/gogs/bachir/debian-web-server)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
receiving_ip=
|
||||
receiving_user=
|
||||
receiving_port=
|
||||
|
||||
site_name=$(ls /var/www/repositories/ | grep -v '^cms')
|
||||
db_password=$(cat /var/www/repositories/cms*/.env | grep DB_PASSWORD | sed "s/[^']*'\([^']*\)'.*/\1/")
|
||||
current_date=$(date +'%d-%m-%y_%H-%M')
|
||||
|
||||
export_folder="~/backup/${site_name}_export_${current_date}"
|
||||
|
||||
mkdir -p "${export_folder}"
|
||||
|
||||
mysqldump -u directus -p"${db_password}" directus > "${export_folder}/db_${site_name}_${current_date}.sql"
|
||||
cp -r /var/www/repositories/cms*/uploads "${export_folder}"
|
||||
cp -r /var/www/repositories/cms*/.env "${export_folder}"
|
||||
|
||||
tar -czf "${export_folder}.tar.gz" -C ~/backup/ .
|
||||
|
||||
ssh -p $receiving_port $receiving_user@$receiving_ip << 'EOF'
|
||||
|
||||
mkdir -p "~/backups/${site_name}"
|
||||
ls -tp "~/backups/${site_name}" | grep -v '/$' | tail -n +3 | xargs -I {} rm -- {}
|
||||
|
||||
EOF
|
||||
|
||||
scp -P $receiving_port "~/backup/${export_folder}.tar.gz" "${receiving_user}@${receiving_ip}:~/backups/${site_name}"
|
||||
rm -r ~/backup/
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo -e "${PURPLE}${BOLD}Enter the receiving server ip : ${RESET}"
|
||||
read -s receiving_ip
|
||||
echo -e "${PURPLE}${BOLD}Enter the receiving server user : ${RESET}"
|
||||
read -s receiving_user
|
||||
echo -e "${PURPLE}${BOLD}Enter the receiving server port : ${RESET}"
|
||||
read -s receiving_port
|
||||
|
||||
ssh-keygen
|
||||
ssh-copy-id -p ${receiving_port} ${receiving_user}@${receiving_ip}
|
||||
|
||||
install_pkg cron
|
||||
|
||||
cp ../assets/backup.sh ~/backup.sh
|
||||
chmod +x ~/backup.sh
|
||||
|
||||
sed -i "s/^receiving_ip=.*/receiving_ip=$receiving_ip/" ~/backup.sh
|
||||
sed -i "s/^receiving_user=.*/receiving_ip=$receiving_user/" ~/backup.sh
|
||||
sed -i "s/^receiving_port=.*/receiving_ip=$receiving_port/" ~/backup.sh
|
||||
|
||||
cronjob="0 2 * * * ~/backup.sh"
|
||||
|
||||
(crontab -l | grep -F ~/backup.sh) && echo "Cron job already exists" || (crontab -l; echo "$cronjob") | crontab -
|
||||
|
|
@ -97,6 +97,13 @@ if [[ "$answer" == "y" ]]; then
|
|||
. bin/install_directus.sh
|
||||
fi
|
||||
|
||||
# BACKUP
|
||||
echo -e "${PURPLE}${BOLD}Setup backup ? (y/N) ${RESET}"
|
||||
read answer
|
||||
if [[ "$answer" == "y" ]]; then
|
||||
. bin/setup_backup.sh
|
||||
fi
|
||||
|
||||
# NUXT STATIC
|
||||
echo -e "${PURPLE}${BOLD}Install the front-end ? (y/N) ${RESET}"
|
||||
read answer
|
||||
|
|
|
|||
Loading…
Reference in New Issue