Skip to content

MoonLiightz/s3cmd-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Simple s3cmd backup script

This is a simple script that compresses a specified folder and loads it into an aws s3 bucket using s3cmd.

Getting Started

Prerequisites

  • Unix-like operating system
  • s3cmd is a command line tool that makes it possible to put/get files into/from a s3 bucket. Please make sure that s3cmd is installed and configured. Check the s3cmd installation guide here and run s3cmd --configure after installation.
  • zip or tar should be installed
  • A configured aws s3 bucket

Installation

via curl

$ curl -Lo backup https://git.io/fhMJy

via wget

$ wget -O backup https://git.io/fhMJy

via httpie

$ http -do backup https://git.io/fhMJy

via git clone

$ git clone https://github.com/MoonLiightz/s3cmd-backup.git
$ cd s3cmd-backup

Note

Don't forget to give the script execution permissions.

$ chmod +x backup

Configuration

To configure the script, edit the downloaded file with an editor of your choice like nano or something else. At the top of the file you will find some configuration options.

Config Option Description
BACKUP_PATH Path to the location without ending / of the folder which should be saved.
Example: If you want to save the folder myData located in /root than you should set BACKUP_PATH="/root"
BACKUP_FOLDER Name of the folder which should be saved.
Example: Based on the previous example you should set BACKUP_FOLDER="myData"
BACKUP_NAME Name of the backup file. The date on which the backup was created is automatically appended to the name.
Example: If you set BACKUP_NAME="myData-backup" the full name of the backup is myData-backup_year-month-day_hour-minute-second
S3_BUCKET_NAME Name of the s3 bucket where the backups will be stored.
Important: The name of the bucket and not the Bucket-ARN
Example: S3_BUCKET_NAME="mybucket"
S3_BUCKET_PATH Path in the s3 bucket without ending / where the backups will be stored.
Example: S3_BUCKET_PATH="/backups"
COMPRESSION The compression which will be used. Available are zip and tar
Example: For zip set COMPRESSION="zip" and for tar set COMPRESSION="tar"
TMP_PATH Path to a location where files can be temporarily stored. The path must exist.
Example: TMP_PATH="/tmp"

Usage

Basic

The script supports the following functionalities.

Create Backup

This command creates a backup and loads it into the specified s3 bucket.

$ ./backup create

List Backups

With this command you can list the backups stored in the s3 bucket.

$ ./backup list

Download Backup

To download a backup from the s3 bucket to the server you can use this command.

$ ./backup download <filename>

Cron

You can also execute the script with a cronjob. The following example creates a backup every night at 2 a.m.

0 2 * * * <path_to_script>/backup create

License

s3cmd-backup is released under the MIT license.

About

Simple script that compresses a specified folder and loads it into an aws s3 bucket using s3cmd.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages