I realised that an installation of newznab that I’d been playing with and forgotten about has eaten up a substantial amount of HDD space and wanted to delete all the releases. Unfortunately, there’s not an easy way to do this. I managed to work out two ways to do it.
The easier way
Inside your installation, in the
misc/testing folder there will be a file called
Around line 65, before
$rel = $db->query($sql);, add the following code:
// //  delete all releases // $sql = "select ID from releases LIMIT 5000";
Save the file, then run:
This could take a while as it fetches 5000 ID’s at a time and iterates over them, deleting releases as it goes. You can experiment with a number higher or lower than 5000 as you see fit. You’ll need to run the script multiple times.
The faster way
Personally, I didn’t want to wait that long. If you’re comfortable deleting files on disk and truncating database tables, this is the solution for you:
I’m going to assume that you’re in the root folder of your newznab installation when providing commands to run. (This is the one that contains
First, delete all of the old nzb files:
$(cd nzbfiles; for i in `ls`; do rm $i/*.nzb.gz; done)
Then delete all the old covers:
$(cd www/covers; for i in `ls`; do rm $i/*.jpg; done)
Finally, truncate all of the old tables.
mysql -u user -p db_name TRUNCATE TABLE releaseaudio; TRUNCATE TABLE releasecomment; TRUNCATE TABLE releaseextrafull; TRUNCATE TABLE releasefiles; TRUNCATE TABLE releasenfo; TRUNCATE TABLE releases; TRUNCATE TABLE releasesubs; TRUNCATE TABLE releasevideo; TRUNCATE TABLE binaries; TRUNCATE TABLE bookinfo; TRUNCATE TABLE usercart; TRUNCATE TABLE userdownloads; TRUNCATE TABLE parts; TRUNCATE TABLE tvrage; TRUNCATE TABLE episodeinfo; TRUNCATE TABLE animetitles; TRUNCATE TABLE thetvdb;
Then you’re done. Here’s the result for me:
Filesystem Size Used Avail Use% Mounted on /dev/sda1 60G 60G 970M 99% /
Filesystem Size Used Avail Use% Mounted on /dev/sda1 60G 1.1G 59G 2% /
Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter