Some time ago I decided that instead of sharing some space in a hosting service to have all my websites I was going to rent my own private server. I could had plugged one old machine to the network at home and save the money but if I have to pay every month a fee I’m sure I will make good use of it.
Now two years later the experience have proved to be great, I manage remotely my own Ubuntu machine (my knowledge in Unix systems have improved a lot), my own http server (nginx), I have services running (GIT, some node.js scripts) and I’m hosting several websites from some of my friends.
I’m using linode.com (great service) for a virtual machine of 256 MB of RAM (more than what I need), it costs me 20 Euros per month which I think is fair.
Thanks to that I’ve been able to code all kind of crazy ideas which it would had been impossible without my own remote machine, and I encourage to all the webmasters to give it a try one day to pass to a next level.
Something I miss when working in Unix is a good backup service, so today I made my first step into the backups system of my host.
Now when I am in some random folder I can call this command – backmeup name * – it copies all files from this folder matching the wildcard to the backups/$data/name folder. A simple way to have some backups of folders of great importance.
Here is the script:
#!/usr/bin/python print "backing you up, bro" backups_folder = "/home/tamat/backups/" import os,sys,glob,datetime,getpass from subprocess import call wildcard = "*" if len(sys.argv) < 2: print "sorry bro, I need a backup name" sys.exit(0) backup_name = sys.argv files = sys.argv[2:] if len(files) == 0: print "no files to backup, justsayin'" sys.exit(0) now = datetime.datetime.now() folder_name = backups_folder + now.strftime("%Y-%m-%d") + "/" if not os.path.isdir(folder_name): os.mkdir( folder_name ) if backup_name != "" and backup_name != "this": folder_name = folder_name + backup_name + "/" if not os.path.isdir(folder_name): print "creating folder, yo: " + backup_name os.mkdir( folder_name ) text_file = open(folder_name + "backup.log", "a") text_file.write("saved from '"+os.getcwd()+"' by '"+getpass.getuser()+"' on " + now.strftime("%Y-%m-%d %H:%M") + "\n") text_file.close() for file in files: print " + " + file call(["cp","-R",file, folder_name]) print "didit"