# PM2 Settings and Migration

#### You:
i have a pm2 thing named vanta-backend how do i check it settings and move to another vps

#### ChatGPT:
If you have a PM2 process called `vanta-backend`, you can inspect its configuration and migrate it to another VPS.

### 1. View the PM2 process details

```bash
pm2 describe vanta-backend
```

or:

```bash
pm2 show vanta-backend
```

This shows:

- script path
- arguments
- working directory
- interpreter (node, python, etc.)
- restart settings
- environment variables
- log locations

---

### 2. See all PM2 processes

```bash
pm2 list
```

---

### 3. View the exact startup command

```bash
pm2 prettylist
```

or:

```bash
pm2 jlist
```

This outputs JSON containing everything PM2 knows about the app.

You can save it:

```bash
pm2 jlist > pm2-config.json
```

---

### 4. If you're using an ecosystem file

Check:

```bash
ls
ls ecosystem.config.js
ls ecosystem.config.cjs
```

or search:

```bash
find ~ -name "ecosystem.config*"
```

The app may be started from something like:

```javascript
module.exports = {
  apps: [{
    name: "vanta-backend",
    script: "./server.js",
    cwd: "/var/www/vanta-backend",
    env: {
      NODE_ENV: "production"
    }
  }]
}
```

---

### 5. Find where the code lives

```bash
pm2 describe vanta-backend
```

Look for:

```
script path
cwd
```

Example:

```
script path: /var/www/vanta-backend/server.js
cwd: /var/www/vanta-backend
```

That entire directory is what you'll copy to the new VPS.

---

### 6. Save the current PM2 process list

```bash
pm2 save
```

This creates:

```bash
~/.pm2/dump.pm2
```

You can copy that file:

```bash
scp ~/.pm2/dump.pm2 root@NEW_SERVER:~/.pm2/
```

and restore:

```bash
pm2 resurrect
```

---

### 7. Copy the application

For example:

```bash
rsync -avz /var/www/vanta-backend root@NEW_SERVER:/var/www/
```

or:

```bash
scp -r /var/www/vanta-backend root@NEW_SERVER:/var/www/
```

---

### 8. Reinstall dependencies on the new VPS

```bash
cd /var/www/vanta-backend
npm install
```

Then start:

```bash
pm2 start server.js --name vanta-backend
pm2 save
```

---

### To see **everything needed to recreate the process**, run:

```bash
pm2 describe vanta-backend
pm2 prettylist
```

Paste the output (you can redact secrets), and I can tell you exactly what needs to be moved and what commands to run on the new VPS.
