Skip to content
This repository has been archived by the owner on Feb 12, 2020. It is now read-only.
/ duplicity Public archive

An experimental WP-CLI plugin for detecting and deleting duplicate WordPress file attachments.

Notifications You must be signed in to change notification settings

Blobfolio/duplicity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Duplicity

Duplicity is an experimental WP-CLI plugin for detecting and deleting duplicate WordPress file attachments.

Its primary goal is reducing the physical number of files stored on a server, helping to speed up subsequent operations like scan, sync, and backup.

When duplicates are detected, all but the prototype file are deleted from the filesystem. The original attachment IDs, however, are retained to prevent any custom_field relations from breaking (the attachment sources are just remapped to the original).

Table of Contents
  1. Requirements
  2. Installation
  3. Use
  4. License

 

Requirements

  • PHP 5.6+;
  • A *nix OS;
  • WP-CLI;

Duplicity is not compatible with WordPress Multi-Site installations.

 

Installation

You can manually download duplicity.zip and extract it somewhere on your server.

Debian-based servers can also install Duplicity using Blobfolio's APT repository:

# Import the signing key
wget -qO - https://apt.blobfolio.com/public.gpg.key | apt-key add -

# apt.blobfolio.com requires HTTPS connection support.
# This may or may not already be configured on your
# machine. If APT is unable to connect, install:
apt-get install apt-transport-https

# Debian Stretch
echo "deb [arch=amd64] https://apt.blobfolio.com/debian/ stretch main" > /etc/apt/sources.list.d/blobfolio.list

# Ubuntu Artful
echo "deb [arch=amd64] https://apt.blobfolio.com/debian/ artful main" > /etc/apt/sources.list.d/blobfolio.list

# Update APT sources
apt-get update

# Install it! Note: this will also install the "wp-cli"
# package, if not present.
apt-get install wp-cli-duplicity

Once you have the files on your server, they will need to be added to the WP-CLI configuration.

require:
  - /opt/duplicity/index.php

WP-CLI automatically recognizes the following generic configuration paths:

  • /site/root/wp-cli.local.yml
  • /site/root/wp-cli.yml
  • ~/.wp-cli/config.yml

The .deb package comes with an example configuration that can be used if you don't need to specify any other options.

# Install as a symlink.
ln -s /usr/share/duplicity/wp-cli.local.yml /your/preferred/config/path

# Or copy it.
cp -a /usr/share/duplicity/wp-cli.local.yml /your/preferred/config/path

To verify that the plugin is working correctly, cd to a site root and type:

# This should return information about Duplicity's subcommands.
wp duplicity --help

 

Use

Duplicity includes the following commands for managing duplicate file attachments:

Command Description
list Show duplicate and deduplicated files
deduplicate Run file deduplication
orphans Show and/or remove orphaned files
postprocess Manually run postprocess operations

Command reference is available in the usual fashion:

# e.g. type any of the following from a site's root.
wp duplicity list --help
wp duplicity deduplicate --help
wp duplicity orphans --help
wp duplicity postprocess --help

Please make sure you have a backup of your files and database before proceeding!

 

License

Copyright © 2018 Blobfolio, LLC <hello@blobfolio.com>

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

Donations

Bitcoin QR If you have found this work useful and would like to contribute financially, Bitcoin tips are always welcome!

1Af56Nxauv8M1ChyQxtBe1yvdp2jtaB1GF

About

An experimental WP-CLI plugin for detecting and deleting duplicate WordPress file attachments.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published