grab postgres creds automatically for backup closes #285
This commit is contained in:
parent
1034b0b146
commit
6052088eb4
17
backup.sh
17
backup.sh
|
@ -1,13 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
#####################################################
|
||||
|
||||
POSTGRES_USER="changeme"
|
||||
POSTGRES_PW="hunter2"
|
||||
|
||||
#####################################################
|
||||
|
||||
SCRIPT_VERSION="9"
|
||||
SCRIPT_VERSION="10"
|
||||
SCRIPT_URL='https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/backup.sh'
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
|
@ -31,11 +24,9 @@ if [ $EUID -eq 0 ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$POSTGRES_USER" == "changeme" || "$POSTGRES_PW" == "hunter2" ]]; then
|
||||
printf >&2 "${RED}You must change the postgres username/password at the top of this file.${NC}\n"
|
||||
printf >&2 "${RED}Check the github readme for where to find them.${NC}\n"
|
||||
exit 1
|
||||
fi
|
||||
POSTGRES_USER=$(grep -w USER /rmm/api/tacticalrmm/tacticalrmm/local_settings.py | sed 's/^.*: //' | sed 's/.//' | sed -r 's/.{2}$//')
|
||||
POSTGRES_PW=$(grep -w PASSWORD /rmm/api/tacticalrmm/tacticalrmm/local_settings.py | sed 's/^.*: //' | sed 's/.//' | sed -r 's/.{2}$//')
|
||||
|
||||
|
||||
if [ ! -d /rmmbackups ]; then
|
||||
sudo mkdir /rmmbackups
|
||||
|
|
|
@ -7,28 +7,6 @@ Download the backup script:
|
|||
wget https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/backup.sh
|
||||
```
|
||||
|
||||
Edit `backup.sh` with your text editor of choice.
|
||||
|
||||
Change the postgres username/password at the top of the file.
|
||||
You can find this info in the following file:
|
||||
```
|
||||
/rmm/api/tacticalrmm/tacticalrmm/local_settings.py
|
||||
```
|
||||
|
||||
Look for this section and grab the USER / PASSWORD:
|
||||
```python
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'tacticalrmm',
|
||||
'USER': 'someusername',
|
||||
'PASSWORD': 'somepassword',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
From the Web UI, click **Tools > Server Maintenance**
|
||||
|
||||
Choose **Prune DB Tables** from the dropdown and check the `Audit Log` and `Pending Actions` checkboxes, and then click **Submit**
|
||||
|
|
|
@ -25,11 +25,29 @@ Download the restore script.
|
|||
wget https://raw.githubusercontent.com/wh1te909/tacticalrmm/master/restore.sh
|
||||
```
|
||||
|
||||
Edit the restore script with your editor of choice and change the postgres username/password at the top of the file.
|
||||
Edit `restore.sh` with your text editor of choice.
|
||||
|
||||
Refer to the [backup](backup.md) instructions on where to find this info.
|
||||
Change the postgres username/password at the top of the file.
|
||||
You can find this info in the following file:
|
||||
```
|
||||
/rmm/api/tacticalrmm/tacticalrmm/local_settings.py
|
||||
```
|
||||
|
||||
Copy the backup tar file to the new server and then call the restore script, passing it the backup file as the first argument:
|
||||
Look for this section and grab the USER / PASSWORD:
|
||||
```python
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': 'tacticalrmm',
|
||||
'USER': 'someusername',
|
||||
'PASSWORD': 'somepassword',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '5432',
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Copy the [backup](backup.md) tar file to the new server and then call the restore script, passing it the backup file as the first argument:
|
||||
|
||||
```bash
|
||||
chmod +x restore.sh
|
||||
|
|
Loading…
Reference in New Issue