Skip to content

Latest commit

 

History

History
96 lines (61 loc) · 3.54 KB

File metadata and controls

96 lines (61 loc) · 3.54 KB

To set up BorgBackup to back up the contents of /media/veracrypt1/myfiles and store the backup in /media/veracrypt1/backup, you can follow these steps:

1. Install BorgBackup (if not already installed)

If you haven’t installed BorgBackup yet, you can do so using the following command (for a system like Ubuntu/Debian):

sudo apt update
sudo apt install borgbackup

For other systems, you can follow the installation instructions from the BorgBackup documentation.

2. Initialize the Borg Repository

A repository is where Borg stores your backups. You need to initialize a repository in /media/veracrypt1/backup.

Run the following command to initialize the Borg repository:

borg init --encryption=repokey /media/veracrypt1/backup
  • --encryption=repokey enables encryption, which is recommended for security. Borg will generate a key for encrypting the backups.

3. Create the First Backup (Full Backup)

Now you can create your first backup of the /media/veracrypt1/myfiles directory. To do this, use the following borg create command:

borg create /media/veracrypt1/backup::backup-$(date +%Y-%m-%d) /media/veracrypt1/myfiles

Here’s what each part does:

  • /media/veracrypt1/backup::backup-$(date +%Y-%m-%d): This specifies the location where the backup will be stored, with the name of the backup set to the current date (backup-YYYY-MM-DD).
  • /media/veracrypt1/myfiles: This is the directory you want to back up.

4. Optional: Exclude Certain Files (if needed)

If you want to exclude some files or directories from the backup, you can create an exclude file that lists paths to exclude. For example:

echo "/media/veracrypt1/myfiles/ignore_this_folder" > exclude-list.txt

To use the exclude-list.txt when creating the backup, you can modify the command:

borg create --exclude-from exclude-list.txt /media/veracrypt1/backup::backup-$(date +%Y-%m-%d) /media/veracrypt1/myfiles

5. Subsequent Incremental Backups

Once you have the initial backup (full backup), subsequent backups will be incremental. To create the next incremental backup, simply run the same borg create command again:

borg create /media/veracrypt1/backup::backup-$(date +%Y-%m-%d) /media/veracrypt1/myfiles

This will only store the changes made since the last backup.

6. Restore from Backup (if needed)

To restore files from a backup, you can use the borg extract command. For example, to restore the files from backup-2025-01-15:

borg extract /media/veracrypt1/backup::backup-2025-01-15

7. Schedule Regular Backups (Optional)

To automate your backups, you can schedule the backup process using cron (or systemd timers if preferred). For example, to run backups every day at 3 AM:

  1. Open the crontab file with:

    crontab -e
  2. Add a line to schedule the backup:

    0 3 * * * /usr/bin/borg create /media/veracrypt1/backup::backup-$(date +\%Y-\%m-\%d) /media/veracrypt1/myfiles

This will create a backup every day at 3 AM.


Recap:

  1. Initialize Borg repository with encryption.
  2. Create a full backup of /media/veracrypt1/myfiles using borg create.
  3. For subsequent backups, just run borg create again, and Borg will only back up the changes.
  4. Optionally, automate backups using cron.

By following these steps, you can set up and manage regular encrypted backups of /media/veracrypt1/myfiles to /media/veracrypt1/backup.