Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)

Easily Backup Your Minecraft Server to Amazon S3

By: Jon on Feb 17th, 2012  |  syntax: None  |  size: 3.31 KB  |  hits: 144  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Here at the Diamond Mine community, we backup our server (worlds, plugins, etcetera) every day to Amazon’s Simple Storage Service (S3). If our map, or other file, were to ever become corrupt, we have a backup of that file readily available for download within seconds. S3 is extremely cheap, most of your cost will not even be for storage, but for PUT and GET requests. Not having enough disk space may be a problem for you; however, when you backup with the provided method below, files are simply transfered to your S3 bucket. Amazon S3 is a highly durable and secure method of backing up your data.
  2. In this tutorial we will be installing everything on a CentOS server – but we’ve provided commands to use if you aren’t. We will be installing s3fs, which is how we will be mounting your Amazon S3 bucket on your file system. s3fs depends on FUSE, which allows s3fs to make a drive on your file system.
  3.  
  4. First off we need to install some packages that we will use for compiling s3fs and FUSE.
  5. CentOS: $ yum groupinstall 'Development Tools'
  6. Debian/Ubuntu: $ apt-get install build-essential libxml2-dev libcurl4-openssl-dev
  7.  
  8. Now we will download, compile, and install FUSE:
  9. $ cd ~
  10. $ wget http://sourceforge.net/projects/fuse/files/latest/download
  11. $ tar -xzf fuse-*.tar.gz && rm -f fuse-*.tar.gz && cd fuse-*
  12. $ ./configure --prefix=/usr/local
  13. $ make && make install
  14. $ export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/
  15. $ ldconfig && modprobe fuse
  16. $ cd .. && rm -rf fuse-*
  17.  
  18. Now s3fs:
  19. $ wget http://s3fs.googlecode.com/files/s3fs-1.61.tar.gz
  20. $ tar -xzf s3fs-*.tar.gz && rm -f s3fs-*.tar.gz && cd s3fs-*
  21. $ ./configure --prefix=/usr/local
  22. $ make && make install
  23. $ cd .. && rm -rf s3fs-*
  24.  
  25. Awesome, now we have both FUSE and s3fs installed. We will now make the script to backup your server, along with the directory that s3fs will mount to. Make the directory where s3fs will mount your S3 bucket to: mkdir /mnt/minecraft. If you will be running the script used to backup the server as a non-root user, be sure to chown the folder.
  26.  
  27. Go to the directory where your Minecraft server is, and make a shell file for the backup script. We will be naming this backup.sh. Paste the below contents into your backup.sh script.
  28. #!/bin/bash
  29. echo -e "\033[32mMounting Amazon S3 bucket as drive for backup.\033[0m"
  30. s3fs S3-BUCKET-NAME /mnt/minecraft
  31. echo -e "\033[32mStarting backup.\033[0m"
  32. rsync -az --delete DIRECTORY-TO-BACKUP /mnt/minecraft
  33. echo -e "\033[32mBackup complete. Unmounting Amazon S3 drive.\033[0m"
  34. /bin/umount /mnt/minecraft
  35. echo -e "\033[32mDone.\033[0m"
  36.  
  37. Be sure to replace S3-BUCKET-NAME and DIRECTORY-TO-BACKUP accordingly. Go to the Amazon Security Credentials page, and find your access key and secret access key. Create the file ~/.passwd-s3fs and enter your keys in the below format.
  38. > accessKeyId:secretAccessKey
  39.  
  40. Now you must secure the credentials file, as it may not have lax permissions. You also need to chmod the shell file you just made.
  41. $ chmod 600 ~/.passwd-s3fs
  42. $ chmod +x backup.sh
  43.  
  44. Done! If you wish to see the script in action, simply run it by executing sh backup.sh. We recommend setting up a cron task to run backup.sh though. It is strongly recommended that you do the first backup manually, as this may take some time for the first sync. After the first backup, only changed files will be backed up.