Posts

Showing posts with the label automate backup

Mount StorageBox to the server for backup

  Quickly  solution Install cifs-utils: apt-get install cifs-utils Adjust and add the following lines to   crontab -e   : # reboot # This one should be moved to /etc/fstab @reboot /sbin/mount.cifs -o user=uXXXXXXXX,pass=xxxxxXXXXXX//uXXXXXX.your-storagebox.be/backup /mnt/storagebox_jobsites_backup/ SAMBA/CIFS You can mount your Storage Box via Samba/CIFS. You can use the following UNC path. If you are using your main account, the share name is  backup . If you are using a sub-account, you must use the username of the sub-account as the username and share name. Linux/Unix: //<username>.your-storagebox.de/<share_name> Windows \\<username>.your-storagebox.de\<share_name> If you use a FritzBox Router from AVM, you need to deactivate the NetBIOS filter for Samba/CIFS to work. Please check the AVM knowledge base for more information.  https://en.avm.de/service/knowledge-base/dok/FRITZ-Box-7590/835_Shared-files-and-printers-o...

Automate PostgreSql Backup with Cron

  Create The  Postgres Password File The file  .pgpass  in a user’s home directory can contain passwords to be used if the connection requires a password (and no password has been specified otherwise). On Microsoft Windows the file is named  %APPDATA%\postgresql\pgpass.conf  (where  %APPDATA%  refers to the Application Data subdirectory in the user’s profile). Alternatively, the password file to use can be specified using the connection parameter passfile or the environment variable  PGPASSFILE . Let’s see if the  postgres user  already has a password: sudo -u postgres psql select * from pg_authid; If  rolpassword  is empty, set the password: ALTER USER postgres PASSWORD 'mypassword'; \q Create  .pgpass vim ~/.pgpass # Add the following line # hostname:port:database:username:password localhost:*:*:postgres:[password] Add Environment variable  PGPASSFILE export PGPASSFILE= '/root/.pgpass' vim /etc/environment ...

Automate borg backups with Cron

Install dependencies To be able send an email from the backup bash command, we have to install mailutils: apt install mailutils Create borg_backup.sh First, create a script which will execute the backups. This could look like the following script and be under  /home/server_backup/scripts/borg_backup.sh . #!/usr/bin/env bash ################################################ #### borg create and borg prune #### #### PLEASE CHECK BACKUP DIRECTORIES #### ################################################ ## ## Set environment variables ## ## if you don't use the standard SSH key, ## you have to specify the path to the key like this export BORG_RSH= "ssh -i /root/.ssh/id_rsa_borg" ## You can save your borg passphrase in an environment ## variable, so you don't need to type it in when using borg # export BORG_PASSPHRASE="top_secret_passphrase" # ACTIVATE VENV source /usr/ local /venvs/borg-env/bin/activate ## ## Set some var...