workflow nextcloud shared

This commit is contained in:
Tykayn 2023-02-06 13:28:35 +01:00 committed by tykayn
parent 317fa59f67
commit 2aa10c4338
33 changed files with 673 additions and 55 deletions

View File

@ -1,55 +0,0 @@
# these bash aliases are meant to be added in your user folder,
# in a file named: .bash_aliases (with the dot at the beginning)
# done for my blog http://www.cipherbliss.com
########## lieux ###########
alias goserv='ssh monUtilisateur@monServeur.com/var/www/html'; # customise this one!
###### lieux locaux
alias gowork='cd /var/www/html/MON-PROJET-EN-COURS'; # customise this one!
alias gowww='cd /var/www/html'
################ symfony3 ######################
alias sf='php bin/console';
alias sfdsu='sf doctrine:schema:update --dump-sql';
alias sfdsuf='sf doctrine:schema:update --force';
alias sfcc='rm -rf app/cache/* && rm -rf app/logs/*';
alias sfdcc='sf doctrine:cache:clear-metadata && sf doctrine:cache:clear-query && sf doctrine:cache:clear-result ';
alias sfdge='sf doctrine:generate:entities Tykayn';
alias sfdsv='sf doctrine:schema:validate';
alias sfdges='sf doctrine:generate:entities Tykayn';
alias sffuc='sf fos:user:change-password';
alias c7='sudo chmod 777 -R';
alias ptest='phpunit -c app';
alias composer='/usr/local/bin/composer.phar';
alias sfad='sf assetic:dump';
alias sfai='sf assets:install';
alias yre='yarn run encore --dev';
alias yrep='yarn run encore --production';
################ system without graphic interface - command line ################
alias basha='nano ~/.bash_aliases'; # éditer les alisas
alias bashare='source ~/.bash_aliases'; # recharger les alias
alias ainstall='sudo apt-get install'; # installer un programme
alias apachere='sudo /etc/init.d/apache2 restart'; # apache restart
alias apacheconf='sudo nano /etc/apache2/apache2.conf'; # fichier de config apache2
alias phpini='sudo nano /etc/php5/apache2/php.ini'; # fichier de config de php5
alias tfa='tail -f /var/log/apache2/error.log'; # suivi des erreurs apache
alias aupg='apt-get update && apt-get upgrade';
################ système with X server ################
alias phpini='sudo gedit /etc/php5/apache2/php.ini';
################ git helpers ################
alias gci='git commit';
alias gco='git checkout';
alias gst='git status';
alias gbr='git branch';
alias gpull='git pull';
alias gpush='git push';
alias gpoush='git push'; # for slipping fingers
alias glg='git log --pretty=oneline';
alias myglg='git log --pretty=oneline --author=tykayn'; # log pour seulement mes commits, utile pour un stand up de projet Agile
alias gaci='git add . --all && git reset -- *.spec.js && git commit -m '; # ajouter sans les tests js, donnez le message du commit entre guillemets suite à cette commande
alias gaaci='git add . --all && git commit -m '; # ajouter sans les tests js
################ other helpers
alias hgrep="history |grep"

139
bash/bash_aliases.sh Executable file
View File

@ -0,0 +1,139 @@
# these bash aliases are meant to be added in your user folder,
# in a file named: .bash_aliases (with the dot at the beginning)
# done for my blog http://www.cipherbliss.com
#!/bin/bash
# these bash aliases are meant to be added in your user folder,
# in a file named: .bash_aliases (with the dot at the beginning)
# done for my blog http://www.cipherbliss.com
############################ current
alias work='cd ~/www/funky-framadate-front \
nvm use 16 && yarn start'
########## lieux ###########
alias goserv='ssh monUtilisateur@monServeur.com/var/www/html'; # customise this one!
alias dok="docker-compose"
alias doc="dok"
alias goc="cd /media/tykayn/catwoman"
###### lieux locaux
alias gok='ssh tykayn@5.196.69.85'
alias goj='ssh -p 3910 tykayn@bbb.liness.org'
alias syncnas='export RSYNC_PASSWORD="blah_blah_blah" && rsync -avP --delete "$USER@192.168.1.8:/volume1/bidules_partagés/videos/*" /home/poule/medias/videos'
alias findup='cd && sudo /usr/share/fslint/fslint/findup |grep a_ranger > duplicates_a_ranger.txt'
alias netre='sudo service network-manager restart'
alias dc='docker-compose'
alias goa='ssh root@biliz.cluster.chapril.org'
alias goo='cd ~/Nextcloud/textes/orgmode'
################ symfony3 ######################
alias sf='php bin/console';
alias sfdsu='sf doctrine:schema:update --dump-sql';
alias sfdsuf='sf doctrine:schema:update --force';
alias sfcc='sf cache:clear';
alias sfdcc='sf doctrine:cache:clear-metadata && sf doctrine:cache:clear-query && sf doctrine:cache:clear-result ';
alias sfdge='sf doctrine:generate:entities';
alias sfdsv='sf doctrine:schema:validate';
alias sfdges='sf doctrine:generate:entities';
alias sffuc='sf fos:user:change-password';
alias c7='sudo chmod 777 -R';
alias ptest='phpunit -c app';
alias composer='/usr/local/bin/composer.phar';
alias sfad='sf assetic:dump';
alias sfai='sf assets:install';
alias yre='yarn run encore --dev';
alias yrep='yarn run encore --production';
################ system without graphic interface - command line ################
alias basha='nano ~/.bash_aliases'; # éditer les alisas
alias bashare='source ~/.bash_aliases'; # recharger les alias
alias ainstall='sudo apt-get install'; # installer un programme
alias apachere='sudo /etc/init.d/apache2 restart'; # apache restart
alias apacheconf='sudo nano /etc/apache2/apache2.conf'; # fichier de config apache2
alias phpini='sudo nano /etc/php8/apache2/php.ini'; # fichier de config de php8
alias tfa='tail -f /var/log/nginx/*.log'; # suivi des erreurs apache
alias aupg='sudo apt-get autoremove && sudo apt-get autoclean && sudo apt-get update -y && sudo apt-get upgrade -y';
################ système with X server ################
alias phpini='sudo gedit /etc/php8/apache2/php.ini';
################ git helpers ################
alias gci='git commit';
alias gco='git checkout';
alias gst='git status';
alias gbr='git branch';
alias gpull='git pull';
alias gpush='git push';
alias gpoush='git push'; # for slipping fingers
alias glg='git log --pretty=oneline';
alias myglg='git log --pretty=oneline --author=tykayn'; # log pour seulement mes commits, utile pour un stand up de projet Agile
alias gaci='git add . --all && git commit -m '; # ajouter sans les tests js, donnez le message du commit entre guillemets suite à cette commande
alias gacio='goo && git add . --all && git commit -m "update orgmode files" && cd -'
alias gaaci='git add . --all && git commit -m '; # ajouter sans les tests js
alias mysr='mysql -uroot -p';
################ other helpers
alias hgrep="history |grep"
alias whatport="sudo netstat -pna | grep "
alias runport="firefox https://localhost:$1"
export RUBY_ENV=devlopment
#cd /media/tykayn/catwoman/stockage-syncable
export GIT_AUTHOR_NAME="Tykayn";
export GIT_AUTHOR_EMAIL="contact@cipherbliss.com";
#export BORG_PASSCOMMAND="cat ~/.borg-passtk4to"
export NVM_DIR="$HOME/.nvm"
alias python=python3
alias py=python3
alias ydl="yt-dlp -o '%(title)s.f%(format_id)s.%(ext)s' "
alias ydla="yt-dlp -o '%(title)s.f%(format_id)s.%(ext)s' "
alias oklm="killall gajim telegram-desktop signal-desktop dino-im"
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
#alias l='ls -CF'
alias l="exa -lh --git --all"
nvm use 16
node --version
export PATH=~/.local/bin:$PATH
export PATH="$HOME/.emacs.d/bin:$HOME/.symfony/bin:$PATH"
CURRENT_YEAR="2022"
# fix mastodon development
# export LD_PRELOAD=libjemalloc.so
export RAILS_ENV=development
########## ---------------- syncro disks ------------------------------------------------------ ##########
echo "load functions to sync files"
source ~/Nextcloud/ressources/workflow_nextcloud/functions_sync.sh
# ----------------------------------------------------------------------
export HISTTIMEFORMAT="%d/%m/%y %T "
export EDITOR=nano
export HUGO_BASE_DIR="~/Nextcloud/textes/hugo"
export PATH=/snap/bin:$PATH
# gestion elixir version ASDF
. ~/.asdf/asdf.sh

View File

@ -0,0 +1,22 @@
#/bin/bash
#
# touch $ARCHIVE_SYNCABLE/.tk-borg-passphrase-light
# remplir le fichier avec les données prises depuis bitwarden
#
# bash /home/tykayn/Nextcloud/projets/rangement/borg_mount.sh
#
# l'archive borg fait 1.3 To
#
echo "monter le borg backup de /home/poule/borg_archives/backup_land4to dans /media/$USER/backup_land4to"
export ARCHIVE_SYNCABLE="/home/poule/encrypted/stockage-syncable" # place where we have our things sorted, other than home
export BORG_PASSCOMMAND="cat /home/$USER/.tk-borg-passphrase-light" # get the borg repo pass
export MEDIA_BORG_REPO="/media/$USER/chaton/borg_archives/backup_land4to"
mkdir /media/$USER/tmp_mount_borg
borg mount /media/$USER/chaton/backup_land4to /media/$USER/tmp_mount_borg
ls -l /media/$USER/tmp_mount_borg
echo "dossier borg monté dans /media/$USER/tmp_mount_borg"

View File

@ -0,0 +1,24 @@
#/bin/bash
#
# touch $ARCHIVE_SYNCABLE/.tk-borg-passphrase-light
# remplir le fichier avec les données prises depuis bitwarden
#
# bash /home/$USER/Nextcloud/projets/rangement/borg_mount.sh
#
# l'archive borg fait 1.3 To
#
echo "monter le borg backup local du disque dada /media/$USER/dada/backup_land4to"
export BORG_PASSCOMMAND="cat /home/$USER/.tk-borg-passphrase-light" # get the borg repo pass
mkdir -p /media/$USER/dada/backup_land4to
mkdir -p /media/$USER/dada/temp_mount_backup_land
rm -rf /media/$USER/dada/backup_land4to/lock.exclusive
borg mount /media/$USER/dada/backup_land4to /media/$USER/dada/temp_mount_backup_land
ls -l /media/$USER/dada/tmp_mount_borg
echo "dossier borg monté dans /media/$USER/tmp_mount_borg"

View File

@ -0,0 +1,19 @@
#/bin/bash
#
# ----------------- documentation -----------------
# tâche à effectuer régulièrement sur les ordis portables
#
# @author functions_sync by @tykayn - contact at cipherbliss.com
# copier le dossier nextcloud dans la home
mkdir ~/.backup_automatique
cd ~/.backup_automatique
git init
rsync ~/Nextcloud/textes/orgmode ~/.backup_automatique --inplace --perms -avP --delete-before
git add .
git commit -m "auto commit de workflow nextcloud - backup nextcloud in user home"

View File

@ -0,0 +1,9 @@
#!/bin/bash
# [[id:6053006f-121e-40a1-ae72-8c1557800e7c][hugo website]]
echo "syncronisation des fichiers org avec le site hugo de démo"
rsync ~/Nextcloud/textes/orgmode/org-roam/*.org ~/www/hugo-essais/quickstart/content/braindump
echo "fichiers org dans hugo"
ls -l ~/www/hugo-essais/quickstart/content/braindump/*.org |wc -l
echo "fichiers markdown"
ls -l ~/www/hugo-essais/quickstart/content/braindump/*.md |wc -l

View File

@ -0,0 +1,11 @@
#/bin/bash
#
# ----------------- documentation -----------------
# tâche à effectuer régulièrement sur les ordis portables
#
# @author functions_sync by @tykayn - contact at cipherbliss.com
# récupérer les notes du mobile et les stocker dans l'incoming inbox orgmode
bash ~/Nextcloud/ressources/workflow_nextcloud/update_calendar.sh
bash ~/Nextcloud/ressources/workflow_nextcloud/get_nextcloud_notes_todo.sh
bash ~/Nextcloud/ressources/workflow_nextcloud/backup_nextcloud_in_user_home.sh

View File

@ -0,0 +1,182 @@
#/bin/bash
# ----------------- documentation -----------------
#
# @author functions_sync by @tykayn - contact at cipherbliss.com
export today=`date` # to log current time
export ARCHIVE_SYNCABLE="/home/poule/encrypted/stockage-syncable" # place where we have our things sorted, other than home
export BORG_PASSCOMMAND="cat $ARCHIVE_SYNCABLE/.tk-borg-passphrase-light" # get the borg repo pass
export SPACESHIP_BORG_REPO="/home/poule/borg_archives/backup_land4to"
export LOG_FILE_BACKUP="$ARCHIVE_SYNCABLE/www/backup/log_backup.log"
export LOG_FILE_BACKUP_DATES="$ARCHIVE_SYNCABLE/www/backup/summary_log_backup.log" # log dates of execution of the script
CURRENT_YEAR="2022"
USER="tykayn"
# --------- log de la date courante -------- #
function logDate()
{
echo "--- $1" | tee -a $LOG_FILE_BACKUP_DATES 2>&1
date "+%Y-%m-%d %H:%M:%S" | tee -a $LOG_FILE_BACKUP_DATES 2>&1
echo "--- " | tee -a $LOG_FILE_BACKUP_DATES 2>&1
}
# --------- gestion des exclusions de rsync -------- #
EXCLUDE=( ".yarn" "cache" ".cache" "Cache" "Steam" "steamapps" ".npm" ".yarn" "node_modules" ".mozilla" "vendor" "Steam" ".rbenv" ".config/borg" "@eaDir" "steamapps" "bower_components")
exclude_opts=()
for item in "${EXCLUDE[@]}"; do
exclude_opts+=( --exclude="$item" )
done
logDate "exclusions de rsync: \n ${exclude_opts[@]}"
# --------- syncro uniquement de borg backup -------- #
# du -sch /home/poule/borg_archives/backup_land4to
function clearDiskSyncBorg()
{
local diskName=$1
echo " " >> $LOG_FILE_BACKUP_DATES
echo " ---------- sync borg folder to disk $diskName " >> $LOG_FILE_BACKUP_DATES
# chech that the disk exists
FILE=/media/$USER/$diskName
if test -d "$FILE"; then
echo "### $FILE , $diskName exists." >> $LOG_FILE_BACKUP_DATES
echo "### ${today} replicate to disk $diskName" >> $LOG_FILE_BACKUP_DATES
logDate "disk $diskName : partie backup_land4to";
# log the date of the last big syncro
touch /home/poule/borg_archives/backup_land4to/last_synced.txt
rm -rf /media/$USER/$diskName/backup_land4to
rsync -avhWP /home/poule/borg_archives /media/$USER/$diskName --perms --delete-before --inplace
else
echo "### $FILE introuvable." >> $LOG_FILE_BACKUP_DATES
fi
date "+%Y-%m-%d %H:%M:%S" | tee -a $LOG_FILE_BACKUP_DATES 2>&1
echo "---- clearDiskSyncBorg $diskName faite -----------------------" | tee -a $LOG_FILE_BACKUP_DATES 2>&1
}
# --------- recopie des éléments de poule zfs -------- #
# les disques de desintation doivent avoir environ 2.5To de place disponible
# chacun doit refléter la partie interne de /home/poule ainsi que le dossier music
function syncToBigDiskName()
{
local diskName=$1
echo " " >> $LOG_FILE_BACKUP_DATES
# chech that the disk exists
FILE=/media/$USER/$diskName
if test -d "$FILE"; then
echo "### $FILE , $diskName exists." >> $LOG_FILE_BACKUP_DATES
echo "### ${today} replicate to disk $diskName" >> $LOG_FILE_BACKUP_DATES
logDate "disk $diskName : part illus";
rsync -avhWP /home/poule/encrypted/dessins_autres_gens /media/$USER/$diskName/encrypted --perms --delete-before --inplace "${exclude_opts[@]}"
rsync -avhWP /home/poule/encrypted/mangas /media/$USER/$diskName/encrypted --perms --delete-before --inplace "${exclude_opts[@]}"
logDate "disk $diskName : part home and installateurs";
rsync -avhWP /home/poule/encrypted/home /media/$USER/$diskName/encrypted --perms --delete-before --inplace "${exclude_opts[@]}"
rsync -avhWP /home/poule/encrypted/installateurs /media/$USER/$diskName/encrypted --perms --delete-before --inplace "${exclude_opts[@]}"
logDate "disk $diskName : part stockage-syncable : photos current year";
rsync -avhWP /home/poule/encrypted/stockage-syncable/photos/$CURRENT_YEAR/* /media/$USER/$diskName/encrypted/stockage-syncable/photos/$CURRENT_YEAR --delete-before --inplace "${exclude_opts[@]}"
logDate "disk $diskName : part stockage-syncable : photos all";
rsync -avhWP /home/poule/encrypted/stockage-syncable/photos/* /media/$USER/$diskName/encrypted/stockage-syncable/photos --delete-before --inplace "${exclude_opts[@]}"
logDate "disk $diskName : part production-servers-backup";
rsync -avhWP /home/poule/borg_archives/production-servers-backup/* /media/$USER/$diskName/borg_archives/production-servers-backup --delete-before --inplace "${exclude_opts[@]}"
logDate "disk $diskName : part encrypted all";
# log the date of the last big syncro
touch /home/poule/encrypted/last_synced.text
rsync -avhWP /home/poule/encrypted/* /media/$USER/$diskName/encrypted --delete-before "${exclude_opts[@]}"
#logDate "disk $diskName : part music";
#rsync -avhWP /home/poule/music /media/$USER/$diskName/ --delete-before --inplace "${exclude_opts[@]}"
else
echo "### $FILE introuvable." >> $LOG_FILE_BACKUP_DATES
fi
date "+%Y-%m-%d %H:%M:%S" | tee -a $LOG_FILE_BACKUP_DATES 2>&1
echo "---- syncToBigDiskName $diskName faite -----------------------" | tee -a $LOG_FILE_BACKUP_DATES 2>&1
}
# ----------------------------------------------------------------------
# --------- le laptop fatland n"a que 2 To de disponible -------- #
function syncfatland()
{
echo " " >> $LOG_FILE_BACKUP_DATES
echo " - envoi vers FATland" >> $LOG_FILE_BACKUP_DATES
#### vers le laptop FATland
rsync /home/poule/encrypted/stockage-syncable/photos/$CURRENT_YEAR tykayn@192.168.1.12:/home/poule/encrypted/stockage-syncable/photos -avhWP --delete-before "${exclude_opts[@]}"
rsync -avhWP /home/poule/encrypted/stockage-syncable/photos/* tykayn@192.168.1.12:/home/poule/encrypted/stockage-syncable/photos --delete-before "${exclude_opts[@]}"
rsync /home/poule/encrypted/stockage-syncable tykayn@192.168.1.12:/home/poule/encrypted -avhWP --delete-before "${exclude_opts[@]}"
rsync /home/poule/encrypted/mangas/* tykayn@192.168.1.12:/home/poule/encrypted/mangas -avhWP --delete-before "${exclude_opts[@]}"
rsync /home/poule/encrypted/home/* tykayn@192.168.1.12:/home/poule/encrypted/home -avhWP --delete-before "${exclude_opts[@]}"
rsync /home/poule/borg_archives/* tykayn@192.168.1.12:/home/poule/borg_archives -avhWP --delete-before
date | tee -a $LOG_FILE_BACKUP_DATES 2>&1
echo "sync fatland fait" | tee -a $LOG_FILE_BACKUP_DATES 2>&1
}
# --------- serveurs web -------- #
# retrieve web servers data to zfs spaceship
# récup des borg backup des serveurs web
function getWebServersBorg()
{
echo " " >> $LOG_FILE_BACKUP_DATES
echo "### ${today} copy of servers borg_backup production contents " | tee -a $LOG_FILE_BACKUP_DATES 2>&1
rsync -avzhWP --perms --delete-before tykayn@peertube.cipherbliss.com:/home/$USER/backup/borgbackup_peertube /home/poule/borg_archives/production-servers-backup/spare & rsync -avzhWP --perms --delete-before tykayn@www.cipherbliss.com:/home/$USER/backup/borgbackup_soy /home/poule/borg_archives/production-servers-backup/soyoustart & rsync -avzhWP --perms --delete-before tykayn@peertube.cipherbliss.com:/home/$USER/backup/serveurs-production/borgbackup_cloudland /home/poule/borg_archives/production-servers-backup/cloud
}
# ----------------- BORG -----------------
# partie contenant tout stockage-syncable
function upBorg()
{
killall borg
logDate "### --------- SPACESHIP | creating borg archive at $SPACESHIP_BORG_REPO"
rm -rf /home/$USER/.cache/borg/150867528afd85114c8aba98af201a7ad8cf01869c507a87c025d2f8701040a9/lock.exclusive
rm -rf $SPACESHIP_BORG_REPO/lock.exclusive
borg create $SPACESHIP_BORG_REPO::encrypted_spaceship_{now} $ARCHIVE_SYNCABLE /home/poule/encrypted/home/$USER /home/poule/encrypted/dessins_autres_gens /home/poule/encrypted/bidules_partagés_backup /home/poule/encrypted/installateurs "${exclude_opts[@]}" --progress --verbose --stats --compression zstd,9 | tee -a $LOG_FILE_BACKUP 2>&1
echo " " | tee -a $LOG_FILE_BACKUP 2>&1
logDate "### --------- ${today} | SPACESHIP | pruning old archives" | tee -a $LOG_FILE_BACKUP 2>&1
# nettoyage tk_backup
borg prune -v --list --stats --keep-daily=8 --keep-weekly=6 --keep-monthly=3 --keep-yearly=2 $SPACESHIP_BORG_REPO | tee -a $LOG_FILE_BACKUP 2>&1
logDate "### --------- pruning done"
}
# ---------- manage log git
function logGit_csv()
{
git log --pretty=format:"%cd - %an : %s" --graph --since=8.weeks | tee -a log_boulot.org 2>&1
}
# écrire un log des commits réalisés groupés par jour pour le dossier courant
function logGit_per_day(){
while read -r -u 9 since name
do
until=$(date "+%Y-%m-%d %H:%M:%S" )
echo "$since $name"
echo
GIT_PAGER=cat git log \
--no-merges \
--committer="$name" \
--since="$since 00:00:00 +0000" \
--until="$until 00:00:00 +0000" \
--format=" * [%h] %s"
echo
done 9< <(git log --no-merges --format=$"%cd %cn" --date=short --since=8.weeks | sort --unique --reverse)
}
function logGit_to_org()
{
folder_name=${PWD##*/}
touch log_git_list.org
echo "* Log git $folder_name\n"> log_git_list.org;
pwd >> log_git_list.org;
cat log_git_list.org;
logGit_per_day | tee -a log_git_list.org 2>&1
}

View File

@ -0,0 +1,27 @@
#!/bin/bash
touch ~/Nextcloud/textes/orgmode/incoming_inbox.org
# comparer le fichier de todo de nextcloud et le fichier modèle de base_inbox.org
# si une différence est notée, migrer les notes
if ! cmp ~/Nextcloud/Notes/todo.txt ~/Nextcloud/textes/orgmode/base_inbox.org >/dev/null 2>&1
then
echo "====== les deux fichiers sont différents"
echo " "
echo "====== lignes à copier des notes de nextcloud: "
echo " "
sed -i 's/\*\ /\*\*\ /g' ~/Nextcloud/Notes/todo.txt
cat ~/Nextcloud/Notes/todo.txt
cat ~/Nextcloud/Notes/todo.txt >> ~/Nextcloud/textes/orgmode/incoming_inbox.org
echo "====== copiées dans ~/Nextcloud/textes/orgmode/incoming_inbox.org"
echo " "
echo "====== lignes dans l'incoming_inbox.org"
cat ~/Nextcloud/textes/orgmode/base_inbox.org > ~/Nextcloud/Notes/todo.txt
echo "====== copied ~/Nextcloud/Notes/todo.txt to incoming_inbox.org"
else
echo "====== Rien à rajouter dans le fichier incoming inbox"
fi

View File

@ -0,0 +1,7 @@
#!/bin/bash
# auto commit periodically
# add this script in crontab
cd ~/Nextcloud/textes/orgmode
git add .
git commit -m "auto commit in $hostname"

View File

@ -0,0 +1,8 @@
#!/bin/bash
git config --global credential.helper 'store'
git config --global user.email "contact@cipherbliss.com"
git config --global user.name "tykayn"
git config --global rerere.enabled true
git config --global init.defaultBranch main
git config --global checkout.defaultRemote origin

View File

@ -0,0 +1,200 @@
#/bin/bash
# ----------------- documentation -----------------
#
# @author sync_spaceship by @tykayn - contact at cipherbliss.com
#
# L'archive Borg contient stockage syncable et vise à être mise dans le NAS pour la postérité
# BORG_NEW_PASSPHRASE=mon_pass_bien_compliqué borg init -e=repokey /home/poule/borg_archives/backup_land4to
# borg create --compression lzma,9 /home/poule/borg_archives/backup_land4to::backup_land4to_{now}
#
#
# à installer en cronjob avec:
# crontab -e
#
# m h dom mon dow command
# */30 * * * * bash ~/sync_spaceship.sh
#
# ----------------- configs -----------------
# functions_sync.sh définit les constantes utiles
LOGIN_NAS="tykayn@192.168.1.15"
source ~/Nextcloud/ressources/workflow_nextcloud/functions_sync.sh
logDate ' start backup script from sync_spaceship script'
logDate "${pwd} sync_spaceship.sh"
logDate ' stop all rsync jobs'
killall rsync;
# ------------------
logDate ' copie du script actuel'
cp ~/.bash_aliases $ARCHIVE_SYNCABLE/archivage/__scripts_syncro
cp ~/.emacs $ARCHIVE_SYNCABLE/archivage/__scripts_syncro
cp ~/Nextcloud/ressources/workflow_nextcloud/sync_spaceship.sh $ARCHIVE_SYNCABLE/archivage/__scripts_syncro
cp ~/.bash_aliases ~/Nextcloud/ressources/workflow_nextcloud/install
cp ~/.emacs ~/Nextcloud/ressources/workflow_nextcloud/install
echo ' ' >> $LOG_FILE_BACKUP_DATES
echo "### ${today} start backup script from sync_spaceship script" >> $LOG_FILE_BACKUP_DATES
echo ' ' >> $LOG_FILE_BACKUP_DATES
echo "### ${today} list of debian apt packages saved in borg_archives list_of_debian_apt_packages.txt" >> $LOG_FILE_BACKUP_DATES
# save a list of apt packages
# to restore it:
# dpkg --set-selections < list_of_debian_apt_packages.txt
dpkg --get-selections>~/list_of_debian_apt_packages.txt
# back pictures to ARCHIVE_SYNCABLE
logDate 'copy of Nextcloud InstantUpload photos'
mv ~/Nextcloud/inbox/instantUpload/* "$ARCHIVE_SYNCABLE/photos/$CURRENT_YEAR" | tee -a $LOG_FILE_BACKUP 2>&1
echo ' ' >> $LOG_FILE_BACKUP_DATES
echo "### ${today} medias in $ARCHIVE_SYNCABLE/photos/$CURRENT_YEAR" >> $LOG_FILE_BACKUP_DATES
ls -l "$ARCHIVE_SYNCABLE/photos/$CURRENT_YEAR" | wc -l | tee -a $LOG_FILE_BACKUP 2>&1
logDate ' Screenshots et Download'
mv ~/Nextcloud/inbox/InstantUpload/Screenshots/* "$ARCHIVE_SYNCABLE/photos/screenshots" | tee -a $LOG_FILE_BACKUP 2>&1
mv ~/Nextcloud/inbox/InstantUpload/Download/* "$ARCHIVE_SYNCABLE/BAZAR" | tee -a $LOG_FILE_BACKUP 2>&1
logDate 'update local nextcloud to stockage syncable';
rsync -avhWP --perms --inplace --delete-before ~/Nextcloud/* $ARCHIVE_SYNCABLE/archivage/clouds/Nextcloud | tee -a $LOG_FILE_BACKUP 2>&1
# --------- copier la home dans les archives ------------
logDate 'update home backup';
rsync -avhWP --inplace --delete-before ~/* /home/poule/encrypted/stockage-syncable/archivage/home "${exclude_opts[@]}" --exclude 'Nextcloud' --exclude 'www' | tee -a $LOG_FILE_BACKUP 2>&1
# --------- sauver les dossiers de développement dans l'archive stockage syncable sans supprimer les projets présents -------- #
logDate 'WWW et HTML sauver les dossiers de développement';
rsync -avP /home/tykayn/www/* /home/poule/encrypted/stockage-syncable/www/development/html "${exclude_opts[@]}"
rsync -avP /var/www/html/* /home/poule/encrypted/stockage-syncable/www/development/html "${exclude_opts[@]}"
# ----------------------------------------------------------------------
# --------- disques -------- #
# - blue 4To (squatt à lyon)
# - brossadent 4To
# - chaton 5To (usb boitier)
# - lilia 4To
# - louisbraille 4To
# - brossadent 4To (squatt à vovo)
# -|(disque sur dock)
# |--|
# | |- moonmoon 3To
#  | |- rondoudou 1To --- non chiffré
# |
# |--|
# |- catwoman 4To (dans le NAS)
# - Taiga 1To
echo "le log de backup se situe dans : $LOG_FILE_BACKUP_DATES"
# --------- mettre à jour les borg backup des serveurs distants -------- #
# getWebServersBorg;
# --- raspberry pi ---------- #
logDate 'update local backup de domoticz vers stockage-syncable/www/backup/domoticz/synced';
rsync -avhWP pi@192.168.1.2:/home/pi /home/poule/encrypted/stockage-syncable/www/backup/domoticz/synced --delete-before --inplace
# --- maj borg de stockage syncable ---------- #
upBorg;
# --------- disques avec beaucoup de place -------- #
# --------- disques chiffrés -------- #
#syncToBigDiskName louisbraille
#syncToBigDiskName rugged
#syncToBigDiskName moonmoon # dernier disque source pour temporisation
#syncToBigDiskName lilia
#syncToBigDiskName # chaton disque en clair pour Optiplex liness
#syncToBigDiskName blue
# --------- disques non chiffrés contenant uniquement les archives borg -------- #
clearDiskSyncBorg kungfu
clearDiskSyncBorg brossadent
clearDiskSyncBorg moonmoon
clearDiskSyncBorg chaton
clearDiskSyncBorg rugged
clearDiskSyncBorg louisbraille
clearDiskSyncBorg lilia
clearDiskSyncBorg blue
# --------- disques de petite taille -------- #
# ne peuvent prendre que le stockage syncable
# ----------- small disks --------------
# syncro vers Taiga de borg
FILE=/media/$USER/Taiga
if test -d "$FILE"; then
echo "### $FILE , Taiga exists." >> $LOG_FILE_BACKUP_DATES
logDate 'Taiga disk monté - sync borg backup';
# rsync -avhWP /home/poule/encrypted/stockage-syncable/* /media/$USER/$diskName/encrypted/stockage-syncable --perms --delete-before --inplace "${exclude_opts[@]}"
rsync -avhWP /home/poule/borg_archives/backup_land4to/* /media/tykayn/Taiga/backup_land4to --delete-before --inplace
else
echo 'Taiga disk NON monté '; >> $LOG_FILE_BACKUP_DATES
fi
# --------- autres pool ZFS -------- #
syncfatland;
## possible amélioration de vitesse de rsync sur les gros dossiers
# ls $dossier_source | xargs -n1 -P4 -I% rsync -Pa % $destination
# ----------------- sync to NAS -----------------
# à destination du NAS, les borg backups perso et de serveurs
logDate ' à destination du NAS: backup_land4to';
rsync -avhWP /home/poule/borg_archives/backup_land4to/* $LOGIN_NAS:/var/services/homes/tykayn/borg_archives/backup_land4to --delete-before --inplace --perms
rsync -avhWP /home/poule/cryptomator/* $LOGIN_NAS:/volume1/bidules_partagés/cryptomator --delete-before --inplace --perms
logDate ' à destination du NAS: production-servers-backup';
#rsync -avhWP /home/poule/borg_archives/production-servers-backup/* $LOGIN_NAS:/var/services/homes/tykayn/borg_archives/production-servers-backup --delete-before --inplace --perms --exclude="@eaDir" "${exclude_opts[@]}"
logDate ' à destination du NAS: vidéos DL';
#rsync -avhWP /home/poule/videos/DOCU-CONF-YOUTUBE/* $LOGIN_NAS:/volume1/bidules_partagés/videos/DOCU-CONF-YOUTUBE --delete-before --inplace --perms
logDate ' à destination du NAS: vidéos';
#rsync -avhWP /home/poule/videos/* $LOGIN_NAS:/volume1/bidules_partagés/videos --delete-before --inplace --perms
logDate ' à destination du NAS: music';
#rsync -avhWP /home/poule/music $LOGIN_NAS:/volume1/music --delete-before --inplace --perms
# en provenance du NAS ----- les bidules partagés
logDate 'en provenance du NAS: bidules_partagés Documents administratifs';
#rsync -avhWP $LOGIN_NAS:/volume1/bidules_partagés/Documents\\\ administratifs /home/poule/encrypted/bidules_partagés_backup --delete-before --inplace --perms "${exclude_opts[@]}"
logDate 'en provenance du NAS: bidules_partagés Briis';
#rsync -avhWP $LOGIN_NAS:/volume1/bidules_partagés/Briis /home/poule/encrypted/bidules_partagés_backup --delete-before --inplace --perms "${exclude_opts[@]}"
logDate 'en provenance du NAS: bidules_partagés Mariage';
#rsync -avhWP $LOGIN_NAS:/volume1/bidules_partagés/Mariage /home/poule/encrypted/bidules_partagés_backup --delete-before --inplace --perms "${exclude_opts[@]}"
logDate 'en provenance du NAS: bidules_partagés wulfila_home sans backups ordi';
#rsync -avhWP $LOGIN_NAS:/volume1/bidules_partagés/wulfila_home /home/poule/encrypted/other_people_content --inplace --exclude=TK-LAND --exclude=musique_tykayn --exclude=windows_backup_laptop_claire --delete-before --inplace --perms "${exclude_opts[@]}"
logDate 'en provenance du NAS: fait';
logDate ' sauver les textes Org'
cd ~/Nextcloud/textes/orgmode && git add . --all && git commit -m "update orgmode files" && cd -
echo "### ${today} end" >> $LOG_FILE_BACKUP_DATES
date -ud "@$SECONDS" | tee -a $LOG_FILE_BACKUP 2>&1
echo "voir les logs: gedit $LOG_FILE_BACKUP"
echo "voir les logs des sections par dates: gedit $LOG_FILE_BACKUP_DATES"
echo " " | tee -a $LOG_FILE_BACKUP 2>&1
echo "taille du BAZAR: $ARCHIVE_SYNCABLE/BAZAR " | tee -a $LOG_FILE_BACKUP 2>&1
du -sch $ARCHIVE_SYNCABLE/BAZAR | tee -a $LOG_FILE_BACKUP 2>&1
date -ud "@$SECONDS" | tee -a $LOG_FILE_BACKUP_DATES 2>&1
echo " " | tee -a $LOG_FILE_BACKUP 2>&1
echo " " | tee -a $LOG_FILE_BACKUP 2>&1
logDate 'fin de sync_spaceship.sh';

View File

@ -0,0 +1,25 @@
#!/bin/bash
# getting a nextcloud calendar without auth and convert it to org file
# add this to a cronjob
#
echo "updating calendar from nextcloud"
#URL="https://cloud.tykayn.fr/remote.php/dav/public-calendars/M2XZMF5KpfmXJcfc\?export" # public link to orgmode calendar of nextcloud https://cloud.tykayn.fr/index.php/apps/calendar/timeGridWeek/now
URL_CAL="https://nuage.tykayn.fr/remote.php/dav/public-calendars/cHkSk5rG445MftpZ?export" # calendrier tkwulfi
echo $URL_CAL
wget $URL_CAL -O orgcalendar.ics --show-progress
# add content of other calendars
#URL_CAL="https://cloud.tykayn.fr/remote.php/dav/calendars/super_admin_tykayn/mobilizonfr/?export"
#wget $URL_CAL -O ->> orgcalendar.ics --show-progress
# annivs
#URL_CAL="https://cloud.tykayn.fr/remote.php/dav/calendars/super_admin_tykayn/contact_birthdays/?export"
#wget $URL_CAL -O ->> orgcalendar.ics --show-progress
# convert the ics to an org file
du -sch orgcalendar.ics
icsorg -i orgcalendar.ics -o calendar.org -p 999999
cat calendar.org |wc -l
cp calendar.org ~/Nextcloud/textes/orgmode
echo "DONE"