# Production guide
+ * [Installation](#installation)
+ * [Upgrade](#upgrade)
+
## Installation
+**Please don't install PeerTube for production on a small device behind a low bandwidth connection because it could slow down the fediverse.**
+
### Dependencies
Follow the steps of the [dependencies guide](dependencies.md).
Install Peertube
```
$ cd ../ && sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
-$ cd ./peertube-latest && sudo -u peertube yarn install --production --pure-lockfile
+$ cd ./peertube-latest && sudo -H -u peertube yarn install --production --pure-lockfile
```
### PeerTube configuration
```
## Upgrade
+#### Auto
+
+Via the bash Script :
+
+```
+$ su - peertube
+$ cd scripts && ./upgrade.sh
+$ exit
+$ systemctl restart peertube
+$ systemctl status peertube
+```
+#### Manuel
Make a SQL backup
```
sudo -u peertube rm peertube-${VERSION}.zip
```
-Change the link to point to the latest version:
+Install node dependencies:
```
-$ cd /var/www/peertube && \
- sudo rm ./peertube-latest && \
- sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
+$ cd /var/www/peertube/versions/peertube-${VERSION} && \
+ sudo -u peertube yarn install --production --pure-lockfile
```
-Install node dependencies:
+Copy new configuration defaults values and update your configuration file:
```
-$ cd /var/www/peertube/peertube-latest && \
- sudo -u peertube yarn install --production --pure-lockfile
+$ sudo -u peertube cp /var/www/peertube/versions/peertube-${VERSION}/config/default.yaml /var/www/peertube/config/default.yaml
+$ diff /var/www/peertube/versions/peertube-${VERSION}/config//production.yaml.example /var/www/peertube/config/production.yaml
```
-Copy new configuration defaults values and update your configuration file:
+Change the link to point to the latest version:
```
-$ sudo -u peertube cp /var/www/peertube/peertube-latest/config/default.yaml /var/www/peertube/config/default.yaml
-$ diff /var/www/peertube/peertube-latest/config//production.yaml.example /var/www/peertube/config/production.yaml
+$ cd /var/www/peertube && \
+ sudo rm ./peertube-latest && \
+ sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest
```
+
Restart PeerTube:
```
$ sudo systemctl restart peertube
$ OLD_VERSION="v0.42.42" && SQL_BACKUP_PATH="backup/sql-peertube_prod-2018-01-19T10:18+01:00.bak" && \
cd /var/www/peertube && rm ./peertube-latest && \
sudo -u peertube ln -s "versions/peertube-$OLD_VERSION" peertube-latest && \
- pg_restore -U peertube -c -d peertube_prod "$SQL_BACKUP_PATH"
+ pg_restore -U peertube -W -h localhost -c -d peertube_prod "$SQL_BACKUP_PATH"
sudo systemctl restart peertube
```