-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,55 @@ | ||
# bakc | ||
simple file backup utility | ||
Simple file backup utility. Nothing special, just something to expedite backing up single files and adding timestamp. | ||
I made this cause I kept wanting a backup of a file prior to editing it so I can roll back if necessary and it all got rather tedious to keep appending timestamp and retaining the path of the file. | ||
|
||
Backup script to speed up the process of backing up system files, appending a date-time and a .bak extension and placing it in my backup dir in home with both hostname and source path. Also includes the option of placing it in working dir and only appending a .bak. | ||
## Installation | ||
```shell | ||
git clone https://github.com/[user]/bakc && \ | ||
cd bakc && \ | ||
chmod u+x install.sh && \ | ||
./install.sh | ||
``` | ||
|
||
takes the options: -w, h currently and default behavior is to add it to current users backup dir | ||
The install script assumes that $HOME/bin is in $path. Change this in install.sh if this is undesirable. | ||
The installer simply symlinks bin file and copies the rc file to ~/.bakcrc. | ||
|
||
## Configuration | ||
.bakcrc allows two config options. | ||
bakc__backup_path is the location you want the files backed up to. | ||
bakc__file_suffix is whatever you want as a suffix for backed up files. By default it creates a timestamp. | ||
|
||
```shell | ||
$ cd /tests | ||
$ bakc -w test.file | ||
# result: | ||
# ./test.file.bak | ||
bakc__backup_path=~/backup | ||
bakc__file_suffix=$(date +"%Y-%m-%d@%T") | ||
``` | ||
|
||
$ bakc test.file | ||
# result: | ||
# ~/.backup/[hostname]/tests/test.file-2015-03-17_10-28-01.bak | ||
## Usage | ||
Backup script to speed up the process of backing up system files, appending a date-time and keeping original folder structure: | ||
```shell | ||
bakc ~/src/bakc/bakc.sh [0] | ||
# backed up '/home/[user]/src/bakc/bakc.sh' to /home/[user]/backup/home/[user]/src/bakc/bakc.sh~2017-02-12@21:20:12 | ||
``` | ||
|
||
Includes the option of placing it in working dir and only appending a .bak file extension | ||
```shell | ||
bakc -w file.txt | ||
# Created test.txt.bak here (pwd) | ||
``` | ||
|
||
Also included is the option to remove source file after backup: | ||
```shell | ||
bakc -wR file.txt | ||
# Created file.txt.bak here (/home/[user]/[path]) | ||
# removed 'file.txt' | ||
``` | ||
|
||
It takes a relative path, and/or multiple files: | ||
```shell | ||
bakc ~/.zprofile ~/.zshenv | ||
# backed up '/home/[user]/.zshenv' to /home/[user]/backup/home/[user]/etc/conf/zsh/.zshenv~2017-02-12@22:01:40 | ||
# backed up '/home/[user]/.zprofile' to /home/[user]/backup/home/[user]/etc/conf/zsh/.zprofile~2017-02-12@22:01:40 | ||
|
||
bakc -w ~/.zshenv ~/.zprofile | ||
# Created /home/[user]/.zshenv.bak here (/home/[user]/src/bakc) | ||
# Created /home/[user]/.zprofile.bak here (/home/[user]/src/bakc) | ||
``` |