Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions docs/gemstones/setup_local_repo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: Setup Local Rocky Linux Repositories
Author: codedude
---

# Introduction
Sometimes you need to have Rocky Repositories local for building virtual machines, lab environments, etc. It can also can help save bandwidth if that is a concern. This article will walk you thru using rsync to copy Rocky repositories to a local web server. Building a web server is out of the scope of this short article.

## Requirements
A web server

## Code
```
#!/bin/bash
repos_base_dir="/web/path"

# Start sync if base repo directory exist
if [[ -d "$repos_base_dir" ]] ; then
# Start Sync
rsync -avSHP --progress --delete --exclude-from=/opt/scripts/excludes.txt rsync://ord.mirror.rackspace.com/rocky "$repos_base_dir" --delete-excluded
# Download Rocky 8 repository key
if [[ -e /web/path/RPM-GPG-KEY-rockyofficial ]]; then
exit
else
wget -P $repos_base_dir https://dl.rockylinux.org/pub/rocky/RPM-GPG-KEY-rockyofficial
fi
fi
```
## Breakdown
This simple shell script uses rsync to pull repository files from the nearest mirror. It also utilizes the "exclude" option which is defined in a text file in the form of keywords that shouldnt be included. Excludes are good if you have limited disk space or just dont want everything for whatever reason. We can use '*' as a wildcard character. Be careful using '*/ng' as it will exclude anything that match those characters. An example is below.

```
*/source*
*/debug*
*/images*
*/Devel*
8/*
8.4-RC1/*
8.4-RC1
```

# End
A simple script that can help save bandwidth or make building out a lab environment a little easier.