How to drop the Ghost posts table?

I am using last years version of Ghost. Now I need to drop parts of my Ghost database, the posts tables, posts_tags table and tags table. I will show you how to make a backup and then restore your backup through the web interface.

Write a readonly database

This is the error when I initially tried to delete the posts:

sqlite> DROP TABLE main.posts;
Error: attempt to write a readonly database

I got the error because of missing write permissions of the Ghost data directory and the ghosts.db file. This worked:

$ chmod -R 777 data

Backup the Ghost Database

$ cp ghost.db ghost.db.bak

Dropping the tables

$ sqlite3 ghost.db
sqlite>DROP TABLE main.posts
sqlite>CREATE TABLE "posts" ("id" integer primary key autoincrement not null, "uuid" varchar(36) not null, "title" varchar(150) not null, "slug" varchar(150) not null, "markdown" text, "html" text, "image" text, "featured" tinyint not null default '0', "page" tinyint not null default '0', "status" varchar(150) not null default 'draft', "language" varchar(6) not null default 'en_US', "meta_title" varchar(150), "meta_description" varchar(200), "author_id" integer not null, "created_at" datetime not null, "created_by" integer not null, "updated_at" datetime, "updated_by" integer, "published_at" datetime, "published_by" integer);

sqlite>CREATE TABLE "posts_tags" ("id" integer primary key autoincrement not null, "post_id" integer not null, "tag_id" integer not null, foreign key("post_id") references "posts"("id"), foreign key("tag_id") references "tags"("id"));

sqlite>CREATE TABLE "tags" ("id" integer primary key autoincrement not null, "uuid" varchar(36) not null, "name" varchar(150) not null, "slug" varchar(150) not null, "description" varchar(200), "parent_id" integer, "meta_title" varchar(150), "meta_description" varchar(200), "created_at" datetime not null, "created_by" integer not null, "updated_at" datetime, "updated_by" integer);

All done. You can use Ghost again. You even don't have to restart it.