Revision Control or Backups

Posted on : 28th Jan 2018
$ cp project-folder project-folder-1

We all have been there, and yes it is embarassing and hectic when you encounter daily backups or daily file changes. Surely you do not want to make changes to prod server or live project without keeping an error free backup of your code or files.

Keeping the modification time in record is important when you are having backups on daily basis, and when you just cp project-folder project-folder-1 you might lose the file attributes, resulting in no record for modification time. However, using cp -p project-folder project-folder-1 preserves the file attributes. Still, not a great solution.

A really cool small bash function to create backup files with timestamp on filename.

# Inside your .bashrc file
function make_backup() {
    new_name=$1.`date +%Y%m%d.%H%M.bak`;
    mv $1 $new_name;
    echo "$1 back up as $new_name ... [OK]";
    cp -p $new_name $1;
$ make_backup /var/log/auth.log

Uploading backups to a remote server ?

You might want to upload timely backups onto a remote server, secure and easy way to do that in my opinion is scp. SCP uses ssh protocol to send and receive encrypted data between servers. Basic syntax for scp :

$ scp local-file-path username@remote-server:/remote/path/where/to/upload/

$ scp username@remote-server:/remote/file/to/receive/ /local/path/where/to/save/


Just the important commands, as you need. Before using Git, set your name and email address :

$ git config --global "Tr3t0n"
$ git config --global ""

Change to the project folder, initialize a git repository, add files to the staging area, commit with a message describing the changes (or describe the feeling at that moment).

$ cd project-folder
$ sudo git init
Initialized empty Git repository in //.git/
$ sudo git add .
$ sudo git commit -m "I dont understand how git works."
[master c30668e] Demo
 1 file changed, 64 insertions(+)
 create mode 100644

Check new files, changed files, staged files or Check the previous commits.

$ sudo git status
$ sudo git log

Voila, and you know how to use Git, understanding Git is on you. Happy backups and version control to you.

© 2021, All Rights Reserved · Vipin Joshi