Peertube – Change Video Settings/Channels from Command Line

Since Peertube uses a Postgres database, we can log in and manually do bulk changes to videos. Things like updating a channel ID, Category, or Privacy can all be easily changed and it is easy to do bulk changes.

Access the Database

Login as the peertube user via ssh

ssh peertube@peertube-ip

Connect to postgres

psql peertube_prod

View videos

select * from video;

There is a bit much information, lets clean it up a bit

select name,category,id,"channelId" from video;

View all the channels. The id field is the channelId that is used in the above video table.

select id,name from "videoChannel";

Change video channel

update video set "channelId" = 100 where id = 123;

Replace 100 with the actual channelId and 123 with the id of the video. Can use the above commands to find that info.

Change Privacy Settings

The privacy settings are what determine if a video is Public, Private etc.

The following command can update the privacy setting for a video

update video set privacy = 3 where id = 101;

There are 4 privacy settings. Change 3 to one of the following.

1 = Public
2 = Unlisted
3 = Private
4 = Internal

Change 101 to the video id you want to change.

You can change the privacy settings for all videos in a channel with something like the following

update video set privacy = 4 where "channelId" = 100;

Checking Postgres version for Matrix-docker-ansible-deploy

https://github.com/spantaleev/matrix-docker-ansible-deploy

When using the above to run a matrix server, it can be confusing how to verify and check which version of Postgres you are running. Fortunately this is really easy to check.

Run

sudo matrix-postgres-cli --version

And you should get the version of Postgres that is being used.

psql (PostgreSQL) 9.6

Backup Matrix Synapse PostgreSQL Database

This is part of a series of posts on backing up and restoring a backup for Matrix Synapse server. Synapse was installed using the matrix-docker-ansible deployment which while a little complicated can greatly ease management later on down the road. All the main components are in docker containers so we need to use docker to access.

https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/maintenance-postgres.md#backing-up-postgresql

As the root user run

docker exec --env-file=/matrix/postgres/env-postgres-psql matrix-postgres pg_dumpall -h matrix-postgres | gzip -c > /matrix/postgres.sql.gz

This will dump the Postgres database in /matrix/postgres.sql.gz
We can use this later to restore to a new server or keep as a backup.