first save up

This commit is contained in:
sparklyballs 2016-08-21 02:57:48 +01:00
commit 37a0f576f8
6 changed files with 72 additions and 0 deletions

16
Dockerfile Normal file
View File

@ -0,0 +1,16 @@
FROM lsiobase/alpine
MAINTAINER sparklyballs
# install packages
RUN \
apk add --no-cache \
curl \
findutils \
git \
python
# add local files
COPY root/ /
# ports and volumes
VOLUME /backup /config

6
README.md Normal file
View File

@ -0,0 +1,6 @@
THIS IS NOT SOMETHING FOR PUBLIC USE
YOU HAVE BEEN WARNED !!!!
HERE BE DRAGONS

2
root/defaults/backup Normal file
View File

@ -0,0 +1,2 @@
21 02 * * * /bin/sh /defaults/script.sh

23
root/defaults/script.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# set variables
unset FOLDER_DATE FOLDER_MAKE REPO_USER
FOLDER_DATE=$(date '+%d-%b-%Y')
FOLDER_MAKE="/backup/${FOLDER_DATE}"
REPO_USER=""
# delete folders older than 20 days
for i in $(find /backup/ -maxdepth 1 -type d -mtime +20 -print); do echo -e "Deleting directory $i";rm -rf $i; done
# make today's folder
if [ -d "${FOLDER_MAKE}" ]; then
rm -rf "${FOLDER_MAKE}"
fi
mkdir -p "${FOLDER_MAKE}" && touch "${FOLDER_MAKE}"
# clone git repositories into todays folder
cd "${FOLDER_MAKE}"
curl -s "https://api.github.com/users/${REPO_USER}/repos?per_page=200" | python -c $'import json, sys, os\nfor repo in json.load(sys.stdin): os.system("git clone " + repo["clone_url"])'
# permissions
chown -R abc:abc "${FOLDER_MAKE}"

View File

@ -0,0 +1,21 @@
#!/usr/bin/with-contenv bash
# copy cronjob to /config
[[ ! -e /config/backup ]] && \
cp /defaults/backup /config/backup
# set user repo
if [[ -z $USER_REPO ]]; then
USER_REPO="linuxserver"
fi
sed -i "s/REPO_USER=\".*\"/REPO_USER=\"${USER_REPO}\"/g" /defaults/script.sh
# set cron job
crontab /config/backup
# permissions
chown -R abc:abc \
/config
chown abc:abc \
/backup

View File

@ -0,0 +1,4 @@
#!/usr/bin/with-contenv bash
/usr/sbin/crond -f -S -l 0 -c /etc/crontabs