• I run a non-profit site for an animal welfare organisation – http://www.darg.org.za – in South Africa.

    The site has been running for a couple of years now, and it is quite photo intensive. I’m looking for a way of backing up all posts older than a certain date, including linked photos. Ideally this will be done to a zip archive which I can then download.

    The reason for this is that my service provider has decided to start charging me personally for the excess space used on the server. The site is big and reasonably popular, so I’m getting nailed for a few hundred bucks a month that I just can’t afford.

    Any ideas and suggestions for how to do this would be greatly appreciated!

Viewing 1 replies (of 1 total)
  • I think the easiest way to back up is just to back up the entire database rather than trying to pick out all the pieces for the older posts.

    As for deleting the posts, you may have to do it in several steps, and I am not sure I know all of them. The post ID is used in several database tables as a reference key.

    I think the approach might be like this:

    • delete all posts where the post_type is ‘post’ and post_date is before a certain date
    • create a temp table of post IDs with post_type = ‘post’ and post_status = ‘publish’
    • delete all posts where the post_type is ‘attachment’ and the ID is not in the temp table
    • delete post_meta where the post_id is not in the temp table
    • delete comments where the comment_post_id is not in the temp table
    • delete commentmeta where the comment_id is not in the comments table
    • delete term_relationships where the object_id is not in the temp table

    That should clean up most of the tables, although there may still be references to old posts buried in the post_contents.

    The images are a different story (and probably a big part of the storage). If they are uploaded into folders by date, you could delete the folders. This may still lead to broken links if some older images were used in later posts. I really don’t have a good answer for that one.

    I hope someone else will chime in here with better info.

Viewing 1 replies (of 1 total)
  • The topic ‘How do I archive and erase bulk old posts?’ is closed to new replies.