teleren/devto huggingface dataset:
Backups with rdiff-backup and mysqldump
Tags: backups, linux, mysql, scripting
Published: 2019-10-20 17:10:24

---
title: Backups with rdiff-backup and mysqldump
published: true
date: 2019-10-19 20:19:28 UTC
tags: Backups,Linux,MySql,Scripting
cover_image: https://thepracticaldev.s3.amazonaws.com/i/wv2de0lpo4g53xdct887.png
canonical_url: https://www.eddinn.net/2019/10/19/backups-with-rdiff-backup-and-mysqldump/
---

I’ve been using rdiff-backup for my server backups along with mysqldump for the sql data for years now, as it gives me the ability to browse the increments on file system level and is extremely efficient and easy to use, both for local files and remote.

> *So what is rdiff-backup anyway?*
> 
> rdiff-backup backs up one directory to another, possibly over a network. The target directory ends up a copy of the source directory, but extra reverse diffs are stored in a special subdirectory of that target directory, so you can still recover files lost some time ago. The idea is to combine **the best features of a mirror and an incremental backup**. rdiff-backup also preserves subdirectories, hard links, dev files, permissions, uid/gid ownership, modification times, extended attributes, acls, and resource forks. Also, rdiff-backup can operate in a **bandwidth efficient** manner over a pipe, like rsync. Thus you can use rdiff-backup and ssh to securely back a hard drive up to a remote location, and only the differences will be transmitted. Finally, rdiff-backup is **easy to use** and settings have sensical defaults.
> 
> – Taken from the official rdiff-backup page, <http://www.nongnu.org/rdiff-backup/>

### Installation

*Important: If you are operating over a network, you’ll have to install rdiff-backup on both servers, preferably both installations of rdiff-backup will have to be the exact same version.*

#### On Ubuntu/Debian:

```bash
apt install librsync-dev rdiff-backup
```

#### On Fedora:

```bash
dnf install librsync rdiff-backup
```

#### On RHEL/CentOS:

```bash
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm
rpm -ivh epel-release-7-9.noarch.rpm
yum install librsync rdiff-backup
```

### rdiff-backup usage examples

#### Backup of a local directory:

```bash
rdiff-backup foo bar
```

#### Backup a local directory to a remote location:

```bash
rdiff-backup /local-dir hostname::/remote-dir
```

#### Restoring a local directory:

```bash
cp -a bar/dir foo/dir
```

#### Restoring files backed up 10 days ago:

```bash
rdiff-backup -r 10D hostname::/remote-dir/file /tmp/file
```

You can also backup and restore from a remote location to another remote location.
*Detailed examples can be found here:* [*http://www.nongnu.org/rdiff-backup/examples.html*](http://www.nongnu.org/rdiff-backup/examples.html)

Here is the original version of the script that I use to backup my web and sql servers to a NFS mount on my backup server:

[**Backup script that utilizes rdiff-backup**](https://github.com/eddinn/backup)
<https://github.com/eddinn/backup>
Failure is not Optional 
Tags: growth
Published: 2019-10-19 19:28:05

I've been hard at work in my job search for almost 3 months now. As I said in my Job Search article, I've had more rejections throughout the process and it's come in different stages of the application process. It's been discouraging knowing what position I'm applying for and it feels like I'm being put through the wringer for the entry-level/junior developer position that I'm applying for. My job search for my first tech job has made me realize how much failure comes with getting what you want.

As this is a tech blog, I can't help but point out the truth that comes before any technical skill you learn being a software engineer, which is how much we depend and thrive off of failure. As software engineers, we depend on error-driven development. We fix error after error until we get a functional application, and then we refactor our code to optimize our app and make it run more smoothly. Which leads to even more errors. 

I wear my heart on my sleeve, which makes me a very open and honest person. When I fail my colleagues know it and when I succeed I like to share it with my colleagues as well. What you see is what you get with me but that doesn't mean I don't change. The pain that I worked through at my boot camp in the General Assembly was getting used to failure itself. Failure early on to becoming a Software Engineer was getting used to errors. I had to work through was I felt I was the only one open to talking about my failures.  Everyone was better at hiding their struggles, where I was open about it. 

My point of this article is to start talking about failure in a more positive light. More importantly, it needs to be talked about in a more positive light because you have no choice in any career, especially the tech field, but to fail if you want to get better. Failure is mandatory in order to get better and I want more people to be open about there failures.
What is Going on With Static Site Generators? Why the numbers are increasing?
Tags: javascript, serverless, webdev, discuss
Published: 2019-10-19 19:11:31


I realized this thing that Static Site Generators are increasing in the community like Global Warming. Every day on Twitter, there must be a guy saying that he made a static site generator different than others. Static Site Generators do what??? 
generate Static Pages through their Templating Language. Is there any need for so many Static Site Generators here, or what are the problems with static site generators which are attracting the developers to make another static site generator. Is there anything we can do about it? JAMSTACK is the future, the headless era is coming.

----
I posted this almost a month ago But I think this can also help you understand the problem. Here is the link : 
{% link https://dev.to/justaashir/static-site-generators-are-not-for-me-my-experience-with-jekyll-hugo-and-netlifycms-4mo5 %}
How To Start Open source contribution
Tags: javascript, angular
Published: 2019-10-19 19:07:52

---
title: How To Start Open source contribution
published: true
description: Need help in open source contribution
tags: javascript, vue, angular
---

<img src="https://thepracticaldev.s3.amazonaws.com/i/r067a9zzricqmez7dt5q.jpg">

Hi I wants to contribute in open source project in frontend technologies, can anybody help me how can I start. What guild lines to follow and to choose a project at first. Thanks.
React Hooks and API Call Sample App
Tags: react
Published: 2019-10-19 18:19:56

Last time around I wrote about a [React sample app with an API call to RandomUser.me](https://dev.to/dileno/react-sample-app-with-api-call-and-update-to-latest-version-30cl).

That version was classic React and now I've updated it to use hooks instead.

With classic React, we used Class components and mutated their internal state via `setState` when we wanted to do something.

With React hooks, we can use functional components instead, with the State hook `useState`, which itself is a React function.

We will import `useState` like this at the top of our file:

`import React, { useState } from "react";`

Then we'll declare our functional component, like this:

`export default function RandomUser() {}`

Then we will use EcmaScript 6 (ES6) destructuring and `useState` to return an array for use in our component:

`const [name, setName] = useState([]);`

The `user` and `setUser` variable names can be anything you want, as long as they are descriptive, of course.

Then we'll use the Effect hook `useEffect` to initialize our function and insert it into the tree. `useEffect` "serves the same purpose as `componentDidMount`, `componentDidUpdate`, and `componentWillUnmount` in React classes, but unified into a single API". ([React Hooks documentation](https://reactjs.org/docs/hooks-overview.html))

Sweet - `useEffect` takes care of a lot for us!

{% gist https://gist.github.com/dileno/949b4cb898809ee013ba6e47f94d08c8 %}

As you can see, we have a call to `fetchRandomUser()`, which will be an async function with our API call.

The complete code looks like this:

{% gist https://gist.github.com/dileno/13311748c6843d5788d6b54b7604863e %}

Compare this functional component with hooks sample, to the [previous class components sample](https://dev.to/dileno/react-sample-app-with-api-call-and-update-to-latest-version-30cl), we now have 48 rows, vs 65 rows before.

[Here's the Github repo](https://github.com/dileno/hello-react/tree/hello-react-hooks)
Learning Javascript #DAY-01 (my journey to full-stack web dev)
Tags: javascript, webdev, computerscience, beginners
Published: 2019-10-19 18:18:51

Hello developers, this is my first ever post on this community channel and will try to pin down all the needed. :)

After trying my hands and getting done with C++, Core Java and some parts of Data Structures now looking ahead to take a dip in the waters of Full-Stack Web development as I am quite familiar with the basics of frontend i.e html+css and having a firm programming background, so now is the time to go for it.

No matter how much Ace-programmer you are, one will start a new language with a simple Hello world program. because we are programmars we start at 0.

I am a c++ guy and after such a long term romance with c++, declaring the variable's type was the only thing I know but javascript shot me blank, I was flabbergasted by the fact that javascript doesn't require any data type you just go and declare that guy ( var name='abcd') or (var age=12) you are done.

I was happy and sad both happy because no dealing with those headaches of declaring the types and sad because will miss my old friends. 

Also, learnt about the basics of concatenation and printing the value out.
made some programs on temperature converter, simple interest. 

Conditionals are quite similar to the previous languages so no new stuff in that.
I found javascript pretty amazing language but yes just, for now, also I have heard about the horrors of it. nevertheless, we as a programmers just keep incrementing :).

Note- any suggestions on learning javascript on getting on full-stack  would be highly welcomed and appreciated

Adios.
Anas Khan.
React SSR using GraphQL and Apollo boilerplate
Tags: react, apollo, graphql, typescript
Published: 2019-10-19 16:57:41

A boilerplate for React with SSR using GraphQL and Apollo

A production-ready boilerplate that you can easily clone it and develop your application using Apollo and Typescript!

Please give it a start if you'd like :)

https://github.com/sepehr1313/react-ssr-apollo-boilerplate

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/emtuttyks04o4n0of5w9.png)
Organization of a tech event
Tags: techtalks, eventsinyourcity, career, productivity
Published: 2019-10-19 16:49:25

Hi, I'm thinking about to organize a sort of event for coders in South Italy. I would offer to participant interesting talks and workshops about software engineering, IT and beyond involving experienced people as speakers.

My region is one of the most beautiful places in the world but now is facing a bad time because young people and students go away to find out a job. 
So, I would like to help create a strong developer community because I think it can help my people work in their land.

I would like to be attractive also for people from other countries.
Indeed, they can find a wonderful place with beautiful beaches and resorts, excellent food, very cheap, sunny and far from the noise of everyday life.

What do you think?
What do you expect to find in a tech event?
Would you take a "work" vacation?
In your opinion, could there be a sort of "boutique" tech event?
Injecting components into re-usable modules with React context?
Tags: discuss, react
Published: 2019-10-19 16:20:28

Here's an idea I've been pondering for awhile:

What if we passed components through React's context API instead of importing them at the top of each component?

Component libraries are great, however, we still have to piece together the components into modules. This way we could "inject" components making the modules easier to style.

I imagine it looking something like this:

```jsx
// Shared module for authentication flows
import { useComponents } from "react-use-components"

export const LoginModule = ({ onLogin }) => {
  // Get the components from `React.useContext`
  const { Button, Form, Input, Label } = useComponents()

  const [state, setState] = useState({ email: "" })
  const [error, setError] = useState(null)

  async function handleSubmit(e) {
    /* call api, handle token, errors etc */
  }
  return (
    <Form onSubmit={handleSubmit}>
      <Label htmlFor="email">
        <Input id="email" value={state.email} />
      </Label>
      <Button type="submit">Login</Button>
    </Form>
  )
}
```
And then set the components to the context in your app:

```jsx
// App.js
import ComponentProvider from "react-use-components"
import { LoginModule, SignupModule } from "standard-auth-module"

import * as Components from "my-awesome-components"

export default ({ navigate }) => (
  <ComponentProvider components={Components}>
    <LoginModule request={api.login} onLogin={user => navigate("/dashboard")} />
  </ComponentProvider>
)
```

Here's how the library would look like:
```js

import React, { createContext, useContext } from "react"

const ComponentContext = createContext()

export const useComponents = () => useContext(ComponentContext)

export const ComponentProvider = ({ components: value, ...props }) =>
  React.createElement(ComponentContext.Provider, { value, ...props })

export default ComponentProvider

```

The point of this would be to build re-usable modules much like an higher abstraction over component libraries. Component libraries would be used for styling and modules for behaviour.

This comes with some obvious challenges like:
- How do we control layout?
- How do we make sure components in the context have the required prop-types? Limit to single element pattern?
- What about performance?
- Translations?


What are your thoughts? What kind of re-usable components could be built?

#### Resources
Demo (https://github.com/carlbarrdahl/react-use-components)
Single Element Pattern (https://github.com/diegohaz/singel)
Do you actually use maths as a developer?
Tags: discuss, watercooler
Published: 2019-10-19 15:54:43

This has always intrigued me as I see a tonne of posts saying that learning maths helps you become a better programmer.

I bloody love a bit of maths, I frequently go through my old notes and look up more and more complex problems to try widen the arsenal. But, to be honest, as a developer day-to-day I very rarely require any form of higher level mathematics to carry out my job. Every now and then I do a little game dev and that requires a reasonable amount: angles etc.

I’m curious to hear what you do and when you use maths as a developer, let me know in the comments.
What are your favorite tricks, techniques, and apps for starting to learn an area of tech you’re completely new to?
Tags: discuss, codenewbie, beginners
Published: 2019-10-19 15:50:39

---
title: What are your favorite tricks, techniques, and apps for starting to learn an area of tech you’re completely new to?
published: true
description: How do you keep track of all the new concepts, figure out where to go, and figure out how to build stuff with your new concepts?
tags: #discuss #codenewbie #beginners
---
Spin up a PostGres Docker Container on the Raspberry Pi in 2 minutes! 🐳
Tags: docker, raspberrypi, devops, database
Published: 2019-10-19 15:08:39

---
title: Spin up a PostGres Docker Container on the Raspberry Pi in 2 minutes! 🐳
published: true
description: This is a Docker Starter-Pack-thingy to help you _up_ a PostGreSQL Database on your Raspberry Pi within seconds. 
tags: #docker, #raspberrypi, #devops, #database
cover_image: https://thepracticaldev.s3.amazonaws.com/i/guclxcb9edctu0dcnamc.png
---

Installing things is difficult! But, it does not need to be. 
[Tobias](https://tobias.hargesheimer.ws/) and me (mostly just Tobias) have already made this easy for you. 

This is a Docker Starter Pack thingy to help you _up_ a PostGreSQL Database on your Raspberry Pi within seconds. 

🐳 

Note, this assumes that you have a gentle grasp of what Docker Compose and Containerization are, so stay put for the rodeo!

[View it on Github](https://github.com/CT83/Raspberry-Pi-PostGres-Docker-Compose) 


## Setup
1. [Install Docker and Docker Compose on the Raspberry Pi]( https://dev.to/rohansawant/installing-docker-and-docker-compose-on-the-raspberry-pi-in-5-simple-steps-3mgl)
2. Clone the [repo](https://github.com/CT83/Raspberry-Pi-PostGres-Docker-Compose) which contains the Compose file `git clone https://github.com/CT83/Raspberry-Pi-PostGres-Docker-Compose.git`
2. Checkout the postgresql.conf, and configure  `listen_addresses` accordingly. By default, the container will be open to all users on the port *5432*.
3. _Up_ the container. `sudo docker-compose up --build -d` 

The container is at **<IP>:5432** with password _password@7979_. You can change this in the [docker-compose.yml](https://github.com/CT83/Raspberry-Pi-PostGres-Docker-Compose/blob/master/docker-compose.yml).
Now, you can treat this like a full fledged PostGres server and do your PG-Admin Stuff. 😇

The PostGres Server can be accessed by any device on the network! 
Use this to build a _truly decentralized off-site infrastructure_ where each container runs on a separate low powered Raspberry Pi Zero, maybe?

### Credits
This would have been impossible without the base image created by [Tobias H](https://github.com/Tob1asDocker). 
*I just added the docker-compose and a conf to allow other network hosts to connect to it*
You can check it out [here](https://github.com/Tob1asDocker/rpi-postgresql)
[Go] Slices which point to the same array may cause side effect
Tags: go, programming
Published: 2019-10-19 14:57:43

# Relationship between slice and array
A slice isn't an array, it's a struct which consists of a pointer to array element, and length of segment, and arr capacity(length). So you can consider it uses pointer and length to slice an array. When you manipulate a slice, it will return new slice, but the array under the hood may not allocate. This may cause side effect.

You can find the source code of slice [here](https://github.com/golang/go/blob/master/src/runtime/slice.go):
```go
type slice struct {
	array unsafe.Pointer
	len   int
	cap   int
}
```

Let's write some code and draw a diagram to represent the concept.

```go
s1:=[]int{1,2,3}
// cut slice : change len
s2:= s1[:2]
// cut slice : change len and pointer to array element
s3 := s1[1:3]
```

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/h5xlsr6hzllev3oimlb7.png)


## Potential issue -- manipulate the same array
Sometimes bug will happen when you manipulate slices both point to the same array. Like the following code, I just want to change the value in S2 only, but it affects s1 and s3, because they both point to the same array.

```go
func main() {
	s1 := []int{1, 2, 3}	
	s2 := s1[:2]
	s3 := s1[1:3]
	fmt.Printf("%v\n%v\n%v\n", s1, s2, s3)
	fmt.Println("-----")

	s2[1] = 0
	fmt.Printf("%v\n%v\n%v\n", s1, s2, s3)
}

output:
[1 2 3]
[1 2]
[2 3]
----------
[1 0 3]
[1 0]
[0 3]
```

## How to avoid?
* just work on the last slice. If you don't need other slice, of course it has no risk,  but if you can't, there's two function to copy new slice.

* use built-in function "func copy(dst, src []Type) int", 
  copy function will only copy elements, based on len of dst, from src

```go
func main() {
	s1 := []int{1, 2, 3}
	s2 := make([]int,2)
	copy(s2, s1)
	s3 := make([]int,2)
	copy(s3, s1[1:])
	fmt.Printf("%v\n%v\n%v\n", s1, s2, s3)
	fmt.Println("-----")

	s2[1] = 0
	fmt.Printf("%v\n%v\n%v\n", s1, s2, s3)
}

output:
[1 2 3]
[1 2]
[2 3]
-----
[1 2 3]
[1 0]
[2 3]
```

* use built-in function "func append(slice []Type, elems ...Type) []Type",
when you append to empty slice, it will allocate the array and make a copy.
```go
func main() {
	s1 := []int{1, 2, 3}
	s2 := append([]int{}, s1...)
	s3 := append([]int{}, s1[1:]...)
	fmt.Printf("%v\n%v\n%v\n", s1, s2, s3)
	fmt.Println("-----")

	s2[1] = 0
	fmt.Printf("%v\n%v\n%v\n", s1, s2, s3)
}
output:
[1 2 3]
[1 2]
[2 3]
-----
[1 2 3]
[1 0]
[2 3]
```

Personally, I prefer to use append, because it's shorter and less code, but append can also make another issue because of allocating. Let's discuss the allocating mechanism in next article.
Announcing: 20 Lists for 2020
Tags: career, meta, yearinreview
Published: 2019-10-19 14:31:13

### I'm proud to announce a new series of articles I've been working on since April of this year: __20 Lists for 2020__.

20 Lists for 2020 is what it sounds like -- a comprehensive series of 20 listicles (of varying lengths) for developers to kick-start your curiosity, fill in the gaps in your knowledge, and better connect you to this community of which we're all a part.

While I initially planned on waiting until December to start releasing these articles, I'm just too excited! I've decided to start sharing them with the world now!

Articles now available include:

1. [20 Most-Recommended Books for Software Developers](https://dev.to/awwsmm/20-most-recommended-books-for-software-developers-5578)
2. [20 Fantastically Bad Predictions Made About Computing and Technology](https://dev.to/awwsmm/20-fantastically-bad-predictions-made-about-computing-and-technology-5gme)
3. [20 Ways to Fight Impostor Syndrome](https://dev.to/awwsmm/20-ways-to-fight-impostor-syndrome-4f84)
4. [20 Small Steps to Become a Regex Master](https://dev.to/awwsmm/20-small-steps-to-become-a-regex-master-mpc)
5. [20 Intriguing, Unusual, and Goofy Programming Languages](https://dev.to/awwsmm/20-intriguing-unusual-and-goofy-programming-languages-238f#toc)
6. [20 Reasons to Move On from Java 8](https://dev.to/awwsmm/20-reasons-to-move-on-from-java-8-1dio)

"20 Reasons to Move On from Java 8" was published on Saturday 23 November. At this point, I need to take a break for a bit (it's Thanksgiving in the USA this week and I'm on vacation). Look for the series to start up again in a few weeks

The series is still in progress, so let me know if you have any ideas for articles, or questions you'd like to see answered. (I have a few posts completely finished, and a bunch more in progress, but all 20 lists aren't yet spoken for!)

Happy reading!

---

_Cover photo by [Kaboompics.com](https://www.pexels.com/@kaboompics?utm_content=attributionCopyText&utm_medium=referral&utm_source=pexels) from [Pexels](https://www.pexels.com/photo/woman-s-hand-using-a-pen-noting-on-notepad-6360/?utm_content=attributionCopyText&utm_medium=referral&utm_source=pexels)_