mirror of
https://github.com/linuxserver/git-backup.git
synced 2026-02-20 04:15:07 +08:00
first save up
This commit is contained in:
commit
37a0f576f8
16
Dockerfile
Normal file
16
Dockerfile
Normal 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
6
README.md
Normal 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
2
root/defaults/backup
Normal file
@ -0,0 +1,2 @@
|
||||
21 02 * * * /bin/sh /defaults/script.sh
|
||||
|
||||
23
root/defaults/script.sh
Normal file
23
root/defaults/script.sh
Normal 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}"
|
||||
21
root/etc/cont-init.d/30-config
Normal file
21
root/etc/cont-init.d/30-config
Normal 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
|
||||
4
root/etc/services.d/cron/run
Normal file
4
root/etc/services.d/cron/run
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/with-contenv bash
|
||||
|
||||
/usr/sbin/crond -f -S -l 0 -c /etc/crontabs
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user