Skip to main content

Adobe

AEM Backup CLI: Rapid Backup/Restore of your AEM instances

AEM Developers, raise your hand if you’ve never broken a local AEM instance. If you did raise your hand, you just might be the most diligent AEM developer out there! Full disclosure, I break my local AEM instances more times than I can count, and usually, I have to redo my local AEM setup.
My manual AEM setup steps include:

  • Redeploy dependencies (ACS commons/connectors/code and content packages)
  • Setup replication agents
  • Setup integrations (such as dynamic media)
  • <insert other manual tasks here>

Every time I break an AEM instance, it’s a major inconvenience and that’s why I wrote AEM Backup CLI. In this post, I will explain how to use it and provide some additional details.

What is AEM Backup CLI

It is a tiny Command Line Interface that packages the AEM crx-quickstart folder so that we can restore it when needed. Everything you set up on an AEM instance is inevitably stored in the filesystem under the crx-quickstart folder, which makes it extremely easy to backup the whole instance. The only caveat, you have to do a backup while your AEM instance is stopped. Which is not bad since you’ll be doing this for local development only.

Installing AEM Backup CLI

  1. If you don’t have it already installed, install Node.js and grab the LTS version
  2. Next, install the CLI: npm install -g aem-backup-cli
  3. You should now be able to run aemb and see the artwork (screenshot below)
  4. Type exit to exit out of the CLI for now.

Before You Backup

Let’s cover some ground rules:

  1. You should only run aemb once you are in the AEM directory. (the directory that contains the AEM jar and the crx-quickstart folder)
  2. You should only run aemb after your AEM instance has been completely shutdown. (see: https://github.com/ahmed-musallam/aem-backup-cli#how-it-works)

Your First Backup

Okay, so now that we’ve covered the ground rules, let’s perform a backup!
Let’s say that I have already installed all my packages and configured everything on my local author instance. And then let’s say that my local author instance is located at /Users/admed.musallam/Development/AEM/6.4. Now, I shutdown my instance and run:

  1.  cd /Users/admed.musallam/Development/AEM/6.4
  2.  aemb

Now I can use any of the aemb commands, you can see those by typing help

Run backup initial-backup-2019.1.24. I named this backup initial-backup-2019.1.24, but you can name it whatever you want. You can also create multiple backups (with different names).

So now you have a backup of the whole AEM instance! This process takes ~7 seconds on my 2014 MackbookPro 2.5GHz Core i7 – 16GB RAM..

Restoring Your Backup

Follow the same steps above but stop your AEM instance, cd into your AEM directory, and run aemb.
And this time, type restore. You will be prompted to select a backup from a list of backups. I went ahead and created 2 other backups:

I selected my original backup and replied y at the prompt:

My backup is now restored and I can start my AEM instance!

Other Commands

The CLI includes two other commands you can use delete and list and they are self-explanatory.

Advanced Usage

Read the documentation to understand how the tool works. Since the tool archives the whole crx-quickstart folder, and adds the archives under crx-quickstart.backups, you can copy any of the generated archives and paste them in a different AEM instance folder (under crx-quickstart.backups. You should be able to use the tool in the same way with the new instance.
Possible scenarios:

  1. You want to copy a certain backup to another AEM instance on your machine
  2. You want to share an AEM backup archive with your fellow developers to get started quickly (granted you have a way to share a ~3GB file)

 
Hope you like the tool and use it in your projects. Please star the repo if you thought it was helpful!
Photo by Mr Cup / Fabien Barral on Unsplash

Tags

Thoughts on “AEM Backup CLI: Rapid Backup/Restore of your AEM instances”

  1. It “should” work on linux but I have not tested it. Give that a shot and let me know.

    As an FYI, this is tool should not be used in production or in any other environment other than your local development machine. For Dev/Prod and others there are other backup tools and practices.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Ahmed Musallam, Adobe Technical Lead

Ahmed is an Adobe Technical Lead and expert in the Adobe Experience Cloud.

More from this Author

Categories
Follow Us