Objective:
Establish a clear policy to generate regular backups of the operating system and data of virtual machines.
Procedure:
- OS copies with Vagrant:
With Vagrant, machines can be easily recreated from the configuration saved in the Vagrantfile, so it is not necessary to make full copies of the operating system. However, it is important to have the box of Vagrant available to quickly recreate any machine. - Data copies with rsync:
Apart from the configuration of the operating system, the data can be protected by scheduled backups with rsync. These files can be copied from the virtual machine to the external hard drive, NAS or to a backup server.
Script examples: #!/bin/bash
-
SOURCE_DIR="/home/user/data/"
-
BACKUP_DIR="/home/usuari/backups/"
-
rsync -avz $SOURCE_DIR $BACKUP_DIR
Automation of backups:
To ensure that backups are made on a regular basis, it can be used cron to run the script automatically. This ensures that files are backed up without the need for manual intervention.
Example cron job:
Automation of backups:
To ensure that backups are made on a regular basis, it can be used cron to run the script automatically. This ensures that files are backed up without the need for manual intervention.
Example cron job:
0 2 * * * /home/usuari/backup.sh
Backup storage:
Data backups can be stored in a local folder or an external server, such as a NAS, to ensure that information is protected in the event of a virtual machine failure.