87 lines
3.3 KiB
HTML
87 lines
3.3 KiB
HTML
<!--
|
|
title: Chat GPT instructions
|
|
description:
|
|
published: 1
|
|
date: 2024-08-18T07:07:49.565Z
|
|
tags:
|
|
editor: ckeditor
|
|
dateCreated: 2024-08-18T07:02:25.195Z
|
|
-->
|
|
|
|
<h1 class="toc-header" id="automatically-transfer-proxmox-backup-to-external-disk"> automatically transfer proxmox backup to external disk</h1>
|
|
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Automating Proxmox Backup Transfer</title>
|
|
</head>
|
|
<body>
|
|
<h1>Automating Proxmox Backup Transfer to an External Hard Disk</h1>
|
|
|
|
<p>You can automate the backup transfer process using a <strong>cron job</strong> that runs every day at 4 AM. This cron job will use the <code>rsync</code> command to copy the backup files from the Proxmox server to the external hard disk, ensuring that only new or modified files are transferred.</p>
|
|
|
|
<h2>1. Mount the External Hard Disk</h2>
|
|
|
|
<p>Ensure that your external hard disk is mounted on a specific directory, for example <code>/mnt/external_backup</code>. You can add an entry in your <code>/etc/fstab</code> to automatically mount the external hard drive on boot:</p>
|
|
|
|
<pre>
|
|
UUID=<your_disk_uuid> /mnt/external_backup ext4 defaults 0 2
|
|
</pre>
|
|
|
|
<p>Replace <code><your_disk_uuid></code> with the actual UUID of your external hard drive. You can find it by running:</p>
|
|
|
|
<pre>
|
|
lsblk -f
|
|
</pre>
|
|
|
|
<h2>2. Create the Cron Job</h2>
|
|
|
|
<p>To create the cron job that will run every day at 4 AM, follow these steps:</p>
|
|
|
|
<ol>
|
|
<li>Open the cron file for editing:</li>
|
|
<pre>
|
|
crontab -e
|
|
</pre>
|
|
|
|
<li>Add the following line to schedule the backup task at 4 AM every day:</li>
|
|
<pre>
|
|
0 4 * * * rsync -av --ignore-existing /path/to/proxmox/backups/ /mnt/external_backup/
|
|
</pre>
|
|
</ol>
|
|
|
|
<h3>Explanation of the <code>rsync</code> Command:</h3>
|
|
<ul>
|
|
<li><code>-a</code>: Archive mode, which preserves permissions, times, symbolic links, etc.</li>
|
|
<li><code>-v</code>: Verbose mode, so you can see what is being transferred.</li>
|
|
<li><code>--ignore-existing</code>: This option ensures that <code>rsync</code> will not overwrite files that already exist on the external hard drive. Only new or modified files will be copied.</li>
|
|
<li><code>/path/to/proxmox/backups/</code>: Replace this with the actual path to your Proxmox backup files.</li>
|
|
<li><code>/mnt/external_backup/</code>: Replace this with the path where your external hard drive is mounted.</li>
|
|
</ul>
|
|
|
|
<h2>Example Cron Job Entry:</h2>
|
|
|
|
<pre>
|
|
0 4 * * * rsync -av --ignore-existing /var/lib/vz/dump/ /mnt/external_backup/
|
|
</pre>
|
|
|
|
<p>This cron job will run at 4 AM every day, copying only new or modified backup files from <code>/var/lib/vz/dump/</code> (the default Proxmox backup directory) to <code>/mnt/external_backup/</code> (the external hard disk).</p>
|
|
|
|
<h2>3. Check Cron Job Status</h2>
|
|
|
|
<p>After adding the cron job, you can verify that it's been added by running:</p>
|
|
|
|
<pre>
|
|
crontab -l
|
|
</pre>
|
|
|
|
<p>This will list all the active cron jobs for the current user.</p>
|
|
|
|
<h2>Conclusion</h2>
|
|
|
|
<p>With this setup, the backup files from Proxmox will automatically be copied to your external hard disk every day at 4 AM. Only files that are not already present on the destination will be transferred, ensuring efficient use of time and storage space.</p>
|
|
</body>
|
|
</html>
|
|
|
|
|