12 Useful Deja Dup Commands

12 Useful Deja Dup Commands

Discover 12 essential Deja Dup commands to enhance your backup management on Linux. Learn how to perform, verify, encrypt, and schedule backups effectively using the command line. Ensure your data is secure and easily recoverable with this comprehensive guide.

Table of Contents

Introduction

Deja Dup is a powerful and user-friendly backup tool that leverages the capabilities of Duplicity, its backend engine. While the graphical user interface (GUI) is intuitive, there are numerous commands available in the command line interface (CLI) that can enhance your backup management. This blog post will explore 12 useful Deja Dup commands that every user should know. By mastering these commands, you can automate, customize, and troubleshoot your backups more effectively.

1. Installing Duplicity

Before you can use Deja Dup commands, you need to ensure that Duplicity is installed on your system. Duplicity is the backend tool that Deja Dup uses for its operations.

				
					sudo apt install duplicity -y # For Ubuntu/Debian Distros
				
			
				
					sudo dnf install deja-dup -y  # For RHEL/CentOS/Linux Distros with EPEL enabled
				
			

2. Performing a Basic Backup

To create a backup of a directory, use the following command:

				
					duplicity /source/directory file:///destination/directory
				
			

For example, to back up your Documents folder to an external drive:

				
					duplicity /home/user/Documents file:///mnt/external/backup
				
			

3. Restoring a Backup

Restoring data from a backup is straightforward with Duplicity. Use the following command to restore your files:

				
					duplicity restore file:///destination/directory /restore/directory
				
			

For instance, to restore the backup from an external drive:

				
					duplicity restore file:///mnt/external/backup /home/user/Documents
				
			

4. Verifying a Backup

To ensure that your backup is complete and correct, you can verify it using:

				
					duplicity verify file:///destination/directory /source/directory
				
			

This command compares the backup to the source directory and lists any differences.

5. Listing Backup Contents

To see the contents of a backup, use:

				
					duplicity list-current-files file:///destination/directory
				
			

This command provides a detailed list of all files and directories in the backup.

6. Incremental Backup

Duplicity supports incremental backups, which only store changes made since the last backup. To create an incremental backup, use:

				
					duplicity list-current-files file:///destination/directory
				
			

Incremental backups are faster and require less storage space compared to full backups.

12 Useful Deja Dup Commands

Photo by admingeek from Infotechys

7. Full Backup

While incremental backups are efficient, it’s also important to perform full backups periodically. To force a full backup, use:

				
					duplicity full /source/directory file:///destination/directory
				
			

Full backups ensure you have a complete copy of your data at a specific point in time.

8. Removing Old Backups

To manage disk space, you may need to remove old backups. Use the following command to delete backups older than a specified number of days:

				
					duplicity remove-older-than 30D file:///destination/directory
				
			

This example removes backups older than 30 days.

9. Cleaning Up Backups

Duplicity can sometimes leave behind incomplete or orphaned backup sets. To clean these up, use:

				
					duplicity cleanup file:///destination/directory
				
			

This command helps maintain a tidy and efficient backup directory.

10. Backup with Encryption

To encrypt your backups for added security, use the --encrypt-key option:

				
					duplicity --encrypt-key YOUR_GPG_KEY /source/directory file:///destination/directory
				
			

Replace YOUR_GPG_KEY with your actual GPG key ID. Encryption protects your data from unauthorized access.

11. Backup with Decryption

To restore an encrypted backup, you need to provide the decryption key:

				
					duplicity --decrypt-key YOUR_GPG_KEY restore file:///destination/directory /restore/directory
				
			

Ensure you have the necessary decryption key to access your data.

12. Scheduling Backups with Cron

Automate your backups by scheduling them with Cron. Open the Cron configuration file:

				
					crontab -e
				
			

Add a line to schedule the backup. For a daily backup at 2 AM, add:

				
					0 2 * * * duplicity /home/user/Documents file:///mnt/external/backup
				
			

This ensures your backups occur automatically without manual intervention.

Summary: Useful Deja Dup Commands

CommandDescription
sudo apt install duplicity -yInstall Duplicity
duplicity /source/dir file:///dest/dirPerform a basic backup
duplicity restore file:///dest/dir /restore/dirRestore a backup
duplicity verify file:///dest/dir /source/dirVerify a backup
duplicity list-current-files file:///dest/dirList backup contents
duplicity incremental /source/dir file:///dest/dirPerform an incremental backup
duplicity full /source/dir file:///dest/dirPerform a full backup
duplicity remove-older-than 30D file:///dest/dirRemove old backups
duplicity cleanup file:///dest/dirClean up backups
duplicity --encrypt-key YOUR_GPG_KEY /source/dir file:///dest/dirBackup with encryption
duplicity --decrypt-key YOUR_GPG_KEY restore file:///dest/dir /restore/dirRestore encrypted backup
0 2 * * * duplicity /home/user/Documents file:///mnt/external/backupSchedule backup with Cron

Conclusion

Deja Dup and its backend, Duplicity, provide a powerful and flexible solution for data backup and recovery. By mastering these 12 commands, you can take full advantage of Deja Dup’s capabilities, ensuring your data is always safe and easily recoverable. Whether you prefer the convenience of the GUI or the control offered by the CLI, Deja Dup has you covered.

Regular backups are essential for data security. Implementing these commands in your backup routine will help you protect your valuable data from loss and ensure that you can recover it quickly when needed.

Did you find this article useful? Your feedback is invaluable to us! Please feel free to share your thoughts in the comments section below.

Related Posts

Leave a Reply

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