-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
4002613
commit e2a33fe
Showing
3 changed files
with
64 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,12 +12,12 @@ tags: | |
|
||
## Prerequisites | ||
|
||
* Know how to install additional repositories and snapshots from the command-line | ||
* Know about mounting filesystems external to your machine (external drive, remote filesystem, and so on.) | ||
* Know how to use an editor (using `vi` here, but you can use your favorite editor) | ||
* Know a little BASH scripting | ||
* Know how to change the crontab for the root user | ||
* Knowledge of SSH public and private keys (only if you plan to run remote backups from another server) | ||
- Know how to install additional repositories and snapshots from the command-line | ||
- Know about mounting filesystems external to your machine (external drive, remote filesystem, and so on.) | ||
- Know how to use an editor (using `vi` here, but you can use your favorite editor) | ||
- Know a little BASH scripting | ||
- Know how to change the crontab for the root user | ||
- Knowledge of SSH public and private keys (only if you plan to run remote backups from another server) | ||
|
||
## Introduction | ||
|
||
|
@@ -224,7 +224,7 @@ Earlier versions of _rsnapshot_ had `hourly, daily, monthly, yearly` but are now | |
|
||
In this example, you are not going to be running any other increments other than a nightly backup. Just add a remark to alpha and gamma. When completed, your configuration file will be: | ||
|
||
``` | ||
```text | ||
#retain alpha 6 | ||
retain beta 7 | ||
#retain gamma 4 | ||
|
@@ -265,7 +265,7 @@ Again, to do this you do not necessarily have to specify the configuration in th | |
|
||
Which will return something similar to this, showing you what will happen when the backup is actually run: | ||
|
||
``` | ||
```bash | ||
echo 1441 > /var/run/rsnapshot.pid | ||
mkdir -m 0755 -p /mnt/backup/storage/beta.0/ | ||
/usr/bin/rsync -a --delete --numeric-ids --relative --delete-excluded \ | ||
|
@@ -305,7 +305,7 @@ If you have not run this before, choose vim.basic as your editor or your own edi | |
|
||
You are going to set your backup to automatically run at 11 PM, so you will add this to the crontab: | ||
|
||
``` | ||
```bash | ||
## Running the backup at 11 PM | ||
00 23 * * * /usr/bin/rsnapshot -c /etc/rsnapshot.conf beta` | ||
``` | ||
|
@@ -318,13 +318,13 @@ If running these backups over the Internet, you need to ensure that each locatio | |
|
||
## Assumptions | ||
|
||
Running _rsnapshot_ from a machine remotely, on-premise. Running this exact configuration is possible remotely off-premise also. | ||
Running _rsnapshot_ from a machine remotely, on-premise. Running this exact configuration is possible remotely off-premise also. | ||
|
||
In this case, you will want to install _rsnapshot_ on the machine that is doing all of the backups. Other assumptions are: | ||
|
||
* That the servers you will be backing up to, have a firewall rule that allows the remote machine to SSH into it | ||
* That each server that you will be backing up has a recent version of `rsync` installed. For Rocky Linux servers, run `dnf install rsync` to update your system's version of `rsync`. | ||
* That you have connected to the machine as the root user, or that you have run `sudo -s` to switch to the root user | ||
- That the servers you will be backing up to, have a firewall rule that allows the remote machine to SSH into it | ||
- That each server that you will be backing up has a recent version of `rsync` installed. For Rocky Linux servers, run `dnf install rsync` to update your system's version of `rsync`. | ||
- That you have connected to the machine as the root user, or that you have run `sudo -s` to switch to the root user | ||
## SSH public or private keys | ||
|
@@ -364,7 +364,7 @@ Next, you want to change rsnapshot_web.conf so that it includes the directories | |
|
||
Here is an example of the web.ourdomain.com configuration: | ||
|
||
``` | ||
```bash | ||
### BACKUP POINTS / SCRIPTS ### | ||
backup [email protected]:/etc/ web.ourourdomain.com/ | ||
backup [email protected]:/var/www/ web.ourourdomain.com/ | ||
|
@@ -393,7 +393,7 @@ Automating backups for the multiple machine or server version is slightly differ | |
|
||
With the content: | ||
|
||
``` | ||
```bash | ||
#!/bin/bash/ | ||
# script to run rsnapshot backups in succession | ||
/usr/bin/rsnapshot -c /etc/rsnapshot_web.conf beta | ||
|
@@ -411,7 +411,7 @@ Create the crontab for root to run the backup script: | |
|
||
Add this line: | ||
|
||
``` | ||
```bash | ||
## Running the backup at 11 PM | ||
00 23 * * * /usr/local/sbin/backup_all | ||
``` | ||
|
@@ -422,7 +422,7 @@ To ensure that everything is backing up according to plan, you might want to sen | |
|
||
## Restoring a backup | ||
|
||
Restoring a few files or an entire backup involves copying the files you want from the directory with the date that you want to restore from back to your machine. | ||
Restoring a few files or an entire backup involves copying the files you want from the directory with the date that you want to restore from back to your machine. | ||
|
||
## Conclusions and other resources | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,13 +13,13 @@ tags: | |
|
||
This is everything you will need to understand and follow along with this guide: | ||
|
||
* A machine running Rocky Linux | ||
* To be comfortable with modifying configuration files from the command-line | ||
* Knowledge of how to use a command line editor (using _vi_ here, but you can use your favorite editor) | ||
* You will need root access, and ideally be signed in as the root user in your terminal | ||
* Public and Private SSH key pairs | ||
* Able to create a bash script with `vi` or your favorite editor, and test it. | ||
* Able to use _crontab_ to automate the running of the script | ||
- A machine running Rocky Linux | ||
- To be comfortable with modifying configuration files from the command-line | ||
- Knowledge of how to use a command line editor (using _vi_ here, but you can use your favorite editor) | ||
- You will need root access, and ideally be signed in as the root user in your terminal | ||
- Public and Private SSH key pairs | ||
- Able to create a bash script with `vi` or your favorite editor, and test it. | ||
- Able to use _crontab_ to automate the running of the script | ||
|
||
## Introduction | ||
|
||
|
@@ -45,18 +45,18 @@ This particular example will use `rsync` on the target machine to pull from the | |
|
||
Before we get terribly carried away with setting up a script, we first need to decide what parameters we want to use with `rsync`. There are many possibilities, so take a look at the [manual for rsync](https://linux.die.net/man/1/rsync). The most common way to use `rsync` is to use the `-a` option, because `-a`, or archive, combines a number of options into one and these are very common options. What does -a include? | ||
|
||
* -r, recurses the directories | ||
* -l, maintains symbolic links as symbolic links | ||
* -p, preserves permissions | ||
* -t, preserves modification times | ||
* -g, preserves group | ||
* -o, preserves owner | ||
* -D, preserves device files | ||
- `-r`, recurses the directories | ||
- `-l`, maintains symbolic links as symbolic links | ||
- `-p`, preserves permissions | ||
- `-t`, preserves modification times | ||
- `-g`, preserves group | ||
- `-o`, preserves owner | ||
- `-D`, preserves device files | ||
|
||
The only other options that we need to specify in this example are: | ||
|
||
* -e, specify the remote shell to use | ||
* --delete, which says if the target directory has a file in it that doesn't exist on the source, get rid of it | ||
- `-e`, specify the remote shell to use | ||
- `--delete`, which says if the target directory has a file in it that doesn't exist on the source, get rid of it | ||
|
||
Next, we need to set up a script by creating a file for it (again, use your favorite editor if you are not familiar with vi). To create the file, just use this command: | ||
|
||
|
@@ -70,7 +70,7 @@ And then make it executable: | |
|
||
Now, scripting makes it super simple and safe so that you can test it fearlessly. Please note that the URL used below is "source.domain.com". Replace it with the domain or IP address of your own source computer, both will work. Also remember that in this example, the script is created on the "target" computer, because the file is pulled from the source computer: | ||
|
||
``` | ||
```bash | ||
#!/bin/bash | ||
/usr/bin/rsync -ae ssh --delete [email protected]:/home/your_user /home | ||
``` | ||
|
@@ -148,25 +148,26 @@ This will pull up the cron, which may look something like this: | |
# | ||
# m h dom mon dow command | ||
``` | ||
|
||
The cron is set up on a 24-hour clock, so what we will need for our entry at the bottom of this file is: | ||
|
||
`00 23 * * * /usr/local/sbin/rsync_dirs` | ||
|
||
What this says is to run this command at 00 minute, 23 h, every day, every month, and every day of the week. Save your cron entry with: | ||
|
||
`Shift : wq!` | ||
++shift+colon+"w"+"q"+exclam++ | ||
|
||
... or with the commands that your favorite editor uses for saving a file. | ||
|
||
## Optional Flags | ||
``` | ||
|
||
```bash | ||
-n : Dry-Run to see what files wouold be transferred | ||
-v : list out all the files which are being transferred | ||
-vvv : to provide debug info while transferring files | ||
-z : to enable compression during the transfer | ||
``` | ||
|
||
## Conclusions | ||
Although `rsync` is not as flexible or powerful as other tools, it provides simple file synchronization, which is always useful. |