Copy user files from Ubuntu or Debian servers to Amazon S3 bucket

If we have several Virtual private servers (VPS) and we need to back up the user data’s and database’s to Amazon S3 we can use a command-line tool to copy the files from VPS server’s to Amazon s3 without pain.

Note: Here My Bucket name is server-backup

First, we need to install with S3 utility.

Add the Key using

# sudo wget -O- -q http://s3tools.org/repo/deb-all/stable/s3tools.key | sudo apt-key add -

Add the Repository

# sudo wget http://s3tools.org/repo/deb-all/stable/s3tools.list -O /etc/apt/sources.list.d/s3tools.list

Update the repository and install the s3 package.

# sudo apt-get update && apt-get install s3cmd

Then Configure the tool to use our amazon s3 storage bucket

# s3cmd --configure

While asking for the below key information provide that information from our initial S3 service setup output.

  • access secret
  • access secret key
  • Choose an encryption password & Confirm too
  • choose if you have HTTP or HTTPS

Here we can create a bucket to upload our files

# s3cmd mb s3://server-backup

If we need to list the created directory use command

# s3cmd ls

Now we can upload a file in our s3 bucket using the put command

# s3cmd put server-backup20.tar.gz s3://server-backup/

If we need to list the file which we have uploaded now use the command

# s3cmd ls s3://server-backup

If we need to download it from S3 bucket use command

# s3cmd get s3://server-backup/server-backup20.tar.gz

To delete the file from S3 bucket use command del

# s3cmd del s3://server-backup/server-backup20.tar.gz

Thus we can copy any user files from Ubuntu or Debian servers to Amazon S3 bucket.