root: add backup_scripts as a project
This commit is contained in:
parent
b278796efd
commit
f7f3e14f41
4
backup-scripts/README.md
Normal file
4
backup-scripts/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# backup-scripts
|
||||
Some basic backup scripts I run on my machine
|
||||
### Usage
|
||||
To get help menu for each script, simply run it without arguments
|
||||
22
backup-scripts/backup_cp.sh
Executable file
22
backup-scripts/backup_cp.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#! /bin/bash
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: ${0} <output_dir> <input_dir>"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set -xe
|
||||
|
||||
out=${1}
|
||||
inp=${2}
|
||||
ts=$(date "+%Y-%m-%d")
|
||||
dirname=$(basename $inp)
|
||||
|
||||
mkdir -p ${out}/${dirname}_backups/
|
||||
mkdir -p ${out}/${dirname}_backups/${ts}_${dirname}
|
||||
cp -pur ${inp}/* ${out}/${dirname}_backups/${ts}_${dirname}
|
||||
|
||||
cd ${out}/${dirname}_backups/
|
||||
ls -1t | tail -n +21 | xargs rm -rf
|
||||
cd -
|
||||
exit 0
|
||||
22
backup-scripts/backup_tar.sh
Executable file
22
backup-scripts/backup_tar.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#! /bin/bash
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "Usage: ${0} <output_dir> <input_dir>"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set -xe
|
||||
|
||||
out=${1}
|
||||
inp=${2}
|
||||
ts=$(date "+%Y-%m-%d")
|
||||
dirname=$(basename $inp)
|
||||
|
||||
mkdir -p ${out}/${dirname}_backups/
|
||||
tar --exclude=.cache --exclude=.vim --exclude=.cargo -zvcf ${out}/${dirname}_backups/${ts}_${dirname}.tar.gz ${inp}
|
||||
|
||||
cd ${out}/${dirname}_backups/
|
||||
ls -1t | tail -n +21 | xargs rm -f
|
||||
cd -
|
||||
exit 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user