Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
The Linux DevOps Handbook

You're reading from  The Linux DevOps Handbook

Product type Book
Published in Nov 2023
Publisher Packt
ISBN-13 9781803245669
Pages 428 pages
Edition 1st Edition
Languages
Concepts
Authors (2):
Damian Wojsław Damian Wojsław
Profile icon Damian Wojsław
Grzegorz Adamowicz Grzegorz Adamowicz
Profile icon Grzegorz Adamowicz
View More author details

Table of Contents (20) Chapters

Preface 1. Part 1: Linux Basics
2. Chapter 1: Choosing the Right Linux Distribution 3. Chapter 2: Command-Line Basics 4. Chapter 3: Intermediate Linux 5. Chapter 4: Automating with Shell Scripts 6. Part 2: Your Day-to-Day DevOps Tools
7. Chapter 5: Managing Services in Linux 8. Chapter 6: Networking in Linux 9. Chapter 7: Git, Your Doorway to DevOps 10. Chapter 8: Docker Basics 11. Chapter 9: A Deep Dive into Docker 12. Part 3: DevOps Cloud Toolkit
13. Chapter 10: Monitoring, Tracing, and Distributed Logging 14. Chapter 11: Using Ansible for Configuration as Code 15. Chapter 12: Leveraging Infrastructure as Code 16. Chapter 13: CI/CD with Terraform, GitHub, and Atlantis 17. Chapter 14: Avoiding Pitfalls in DevOps 18. Index 19. Other Books You May Enjoy

Understanding the backup script – first steps

Now that we know what a script can look like, we can start writing one. You can use your favorite console editor or IDE to do this. Let’s create an empty file named run_backups.sh and change its permissions so that they’re executable:

admin@myhome:~$ touch run_backups.sh && chmod +x run_backups.sh
admin@myhome:~$ ls -l run_backups.sh
-rwxr-xr-x  1 admin  admin  0 Dec  1 15:56 run_backups.sh

It’s an empty file, so we’ll need to add a basic database backup command and proceed from there. We won’t be covering granting this script access to a database. We will be backing up a PostgreSQL database and using the pg_dump tool for that purpose.

Let’s input a shebang line and a pg_dump command call in our base script:

#!/usr/bin/env bash
pg_dump mydatabase > mydatabase.sql

To execute this script, we’ll need to start the following...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}